2007-10-23 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 23 Oct 2007 10:06:35 +0000 (10:06 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 23 Oct 2007 10:06:35 +0000 (10:06 -0000)
* Ping.cs : Do not call OnPingCompleted() at CancelAsync() it should
  be called at RunWorkerCompleted. Simplified RunWorkerCompleted.

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

mcs/class/System/System.Net.NetworkInformation/ChangeLog
mcs/class/System/System.Net.NetworkInformation/Ping.cs

index cc9111c0f45ea1885e78417775e1003e0bd62051..5744afd1d2a07759f7867d8e4cef8708efd53eae 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Ping.cs : Do not call OnPingCompleted() at CancelAsync() it should
+         be called at RunWorkerCompleted. Simplified RunWorkerCompleted.
+
 2007-09-29  Miguel de Icaza  <miguel@novell.com>
 
        * NetworkInterface.cs (GetAllNetworkInterfaces): return an empty
index dc84bd9bb516ae1dd04a9f70c7aa3c57d51151b1..e6ef7e86f6322818ca1ee3a4e776c5bd0f3ddc8f 100644 (file)
@@ -221,10 +221,8 @@ namespace System.Net.NetworkInformation {
                        };
                        worker.WorkerSupportsCancellation = true;
                        worker.RunWorkerCompleted += delegate (object o, RunWorkerCompletedEventArgs ea) {
-                               if (ea.Result is PingReply)
-                                       OnPingCompleted (new PingCompletedEventArgs (null, false, user_async_state, (PingReply) ea.Result));
-                               else
-                                       OnPingCompleted (new PingCompletedEventArgs ((Exception) ea.Result, false, user_async_state, null));
+                               // Note that RunWorkerCompletedEventArgs.UserState cannot be used (LAMESPEC)
+                               OnPingCompleted (new PingCompletedEventArgs (ea.Error, ea.Cancelled, user_async_state, ea.Result as PingReply));
                        };
                        worker.RunWorkerAsync (userToken);
                }
@@ -234,9 +232,8 @@ namespace System.Net.NetworkInformation {
                public void SendAsyncCancel ()
                {
                        if (worker == null)
-                               throw new InvalidOperationException ("Another SendAsync operation is in progress");
+                               throw new InvalidOperationException ("SendAsync operation is not in progress");
                        worker.CancelAsync ();
-                       OnPingCompleted (new PingCompletedEventArgs (null, true, user_async_state, null));
                }
 
                // ICMP message