Changed UploadStringAsync to handle UploadString encapsulated exceptions.
authormarcos henrich <marcoshenrich@gmail.com>
Tue, 3 Jun 2014 15:23:22 +0000 (16:23 +0100)
committermarcos henrich <marcoshenrich@gmail.com>
Tue, 3 Jun 2014 15:23:22 +0000 (16:23 +0100)
UploadString call UploadData that encapsulates all exceptions in a WebException. ThreadInterruptedException were encapsulated into a WebException, so UploadStringAsync now uses e.InnerException is ThreadInterruptedException instead of trying to catch it.

mcs/class/System/System.Net/WebClient.cs

index 7ee338a0a266516d4ed107fcff2920b4d9cd99bd..97f9759dcc32f9675611404754a0cf6fc02eadcf 100644 (file)
@@ -1405,10 +1405,12 @@ namespace System.Net
                                                string data2 = UploadString ((Uri) args [0], (string) args [1], (string) args [2]);
                                                OnUploadStringCompleted (
                                                        new UploadStringCompletedEventArgs (data2, null, false, args [3]));
-                                       } catch (ThreadInterruptedException){
-                                               OnUploadStringCompleted (
-                                                       new UploadStringCompletedEventArgs (null, null, true, args [3]));
                                        } catch (Exception e){
+                                               if (e is ThreadInterruptedException || e.InnerException is ThreadInterruptedException) {
+                                                       OnUploadStringCompleted (
+                                                               new UploadStringCompletedEventArgs (null, null, true, args [3]));
+                                                       return;
+                                               }
                                                OnUploadStringCompleted (
                                                        new UploadStringCompletedEventArgs (null, e, false, args [3]));
                                        }});