2009-03-11 Rolf Bjarne Kvinge <RKvinge@novell.com>
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Wed, 11 Mar 2009 16:49:50 +0000 (16:49 -0000)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Wed, 11 Mar 2009 16:49:50 +0000 (16:49 -0000)
* WebClient_2_1.cs: OnOpenReadCompleted and OnDownloadStringCompleted:
make sure we don't pass any exceptions back to native code.

svn path=/trunk/mcs/; revision=129077

mcs/class/System.Net/System.Net/ChangeLog
mcs/class/System.Net/System.Net/WebClient_2_1.cs

index f16cce527c61af4aa4b0588e7cca669c7703a210..1474d7e32e16e3e46f803fde5855ddbf685ae5ae 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-11  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * WebClient_2_1.cs: OnOpenReadCompleted and OnDownloadStringCompleted:
+       make sure we don't pass any exceptions back to native code.
+
 2009-03-04  Rolf Bjarne Kvinge  <RKvinge@novell.com>
 
        * WebClient_2_1.cs: Stub out missing methods.
index fd7852cb3c88c212a6beaf9e7087fe3c455ce2ee..1a2efcfab6b5221c87663b7b44899b0cc0d19b34 100644 (file)
@@ -1437,7 +1437,26 @@ namespace System.Net
                        CompleteAsync ();
                        if (OpenReadCompleted != null) {
                                ManualResetEvent wait_event = new ManualResetEvent (false);
-                               GSourceFunc callback = (GSourceFunc) delegate (IntPtr ctx) { OpenReadCompleted (this, (OpenReadCompletedEventArgs) callback_args); wait_event.Set (); return false; };
+                               GSourceFunc callback = (GSourceFunc) delegate (IntPtr ctx)
+                               {
+                                       try {
+                                               OpenReadCompleted (this, (OpenReadCompletedEventArgs) callback_args);
+                                       } catch (Exception ex) {
+                                               try {
+                                                       Console.WriteLine ("Unhandled exception: {0}", ex);
+                                               } catch {
+                                               }
+                                       }
+                                       try {
+                                               wait_event.Set ();
+                                       } catch (Exception ex) {
+                                               try {
+                                                       Console.WriteLine ("Unhandled exception: {0}", ex);
+                                               } catch {
+                                               }
+                                       }
+                                       return false;
+                               };
                                callback_args = args;
 
                                g_timeout_add (0, callback, IntPtr.Zero);
@@ -1461,11 +1480,19 @@ namespace System.Net
                                {
                                        try {
                                                DownloadStringCompleted (this, (DownloadStringCompletedEventArgs) callback_args);
+                                       } catch (Exception ex) {
+                                               try {
+                                                       Console.WriteLine ("Unhandled exception: {0}", ex);
+                                               } catch {
+                                               }
+                                       }
+                                       try {
                                                wait_event.Set ();
                                        } catch (Exception ex) {
-                                               Console.WriteLine ("Unhandled exception: {0}", ex);
-                                       } catch {
-                                               Console.WriteLine ("Unhandled exception.");
+                                               try {
+                                                       Console.WriteLine ("Unhandled exception: {0}", ex);
+                                               } catch {
+                                               }
                                        }
                                        return false;
                                };