2008-08-14 Geoff Norton <gnorton@novell.com>
authorGeoff Norton <grompf@sublimeintervention.com>
Thu, 14 Aug 2008 15:42:49 +0000 (15:42 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Thu, 14 Aug 2008 15:42:49 +0000 (15:42 -0000)
        * WebClient_2_1.cs: A dirty hack to emit the events on the proper thread
        until we can figure out exactly how to leverage Dispatcher over here.

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

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

index 28626689b03f28d6d98902e1d27e28352292f4b2..f6ea12d041b97ef9784ad591c5444f633d08fa5f 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-14  Geoff Norton  <gnorton@novell.com>
+
+       * WebClient_2_1.cs: A dirty hack to emit the events on the proper thread
+       until we can figure out exactly how to leverage Dispatcher over here.
+
 2008-06-18  Stephane Delcroix  <sdelcroix@novell.com>
 
        * WebRequest_2_1.cs: Load BrowserHttpWebRequest from the right assembly
index 699bd42509bf60f71077e8bf5a40e39d00ae7051..ab6d24e626e500ecdce1c8a3296969cc4c9d3c48 100644 (file)
@@ -1409,10 +1409,26 @@ namespace System.Net
 //                             DownloadFileCompleted (this, args);
 //             }
 //
+                public delegate bool GSourceFunc  (IntPtr data);
+
+               [DllImport ("moon")]
+               static extern uint g_idle_add (GSourceFunc callback, IntPtr data);
+
+               private DownloadProgressChangedEventArgs e;
+               private GSourceFunc download_progress_delegate;
                protected virtual void OnDownloadProgressChanged (DownloadProgressChangedEventArgs e)
                {
-                       if (DownloadProgressChanged != null)
-                               DownloadProgressChanged (this, e);
+                       if (DownloadProgressChanged != null) {
+                               this.e = e;
+                               download_progress_delegate = new GSourceFunc (download_progress_callback);
+                               g_idle_add (download_progress_delegate, IntPtr.Zero);
+                       }
+               }
+               
+               bool download_progress_callback (IntPtr data)
+               {
+                       DownloadProgressChanged (this, e);
+                       return false;
                }
 
 //             protected virtual void OnDownloadStringCompleted (DownloadStringCompletedEventArgs args)
@@ -1422,11 +1438,22 @@ namespace System.Net
 //                             DownloadStringCompleted (this, args);
 //             }
 //
+               private OpenReadCompletedEventArgs args;
+               private GSourceFunc read_completed_delegate;
                protected virtual void OnOpenReadCompleted (OpenReadCompletedEventArgs args)
                {
                        CompleteAsync ();
-                       if (OpenReadCompleted != null)
-                               OpenReadCompleted (this, args);
+                       if (OpenReadCompleted != null) {
+                               this.args = args;
+                               read_completed_delegate = new GSourceFunc (read_completed_callback);
+                               g_idle_add (read_completed_delegate, IntPtr.Zero);
+                       }
+               }
+
+               bool read_completed_callback (IntPtr data)
+               {
+                       OpenReadCompleted (this, args);
+                       return false;
                }
 
 //             protected virtual void OnOpenWriteCompleted (OpenWriteCompletedEventArgs args)