* AsyncMethodData.cs: Check if the call is complete before doing a
authorJackson Harper <jackson@novell.com>
Thu, 5 Jan 2006 22:18:41 +0000 (22:18 -0000)
committerJackson Harper <jackson@novell.com>
Thu, 5 Jan 2006 22:18:41 +0000 (22:18 -0000)
* WaitOne
        * AsyncMethodResult.cs: We no longer use a WeakReference for the
        AsyncMethodResult, this is because we ALWAYS want the
        ManualResetEvent to get set.
        * Control.cs: When disposing use an async invoke to call
        * shutdown
        code, so that thigns don't block on the finalizer thread.  Also
        check if we even have a message loop before trying to send
        messages, if we don't then don't bother sending messages.
        - No more weak references for async methods
        * XplatUIDriver.cs: No more weak references for async methods.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs

index 758d82300904f0292d6c7423be8468e23001635a..7a001cbc731e0c1103108fafc9907ecff9e1ceb0 100644 (file)
@@ -32,7 +32,7 @@ namespace System.Windows.Forms {
        internal class AsyncMethodData {
                public Delegate Method;
                public object [] Args;
-               public WeakReference Result;
+               public AsyncMethodResult Result;
 #if NET_2_0
                public ExecutionContext Context;
 #else
index bf77db5d5d6263f84c65b77a79517c4b618c0d12..8c52ca71dcc6c94b691e43cf345a54e651512a49 100644 (file)
@@ -67,6 +67,10 @@ namespace System.Windows.Forms {
                
                public object EndInvoke ()
                {
+                       lock (this) {
+                               if (completed)
+                                       return return_value;
+                       }
                        handle.WaitOne ();
                        return return_value;
                }
index 5cf50040c2e12428483d77677cd37d6e1c34db1a..db30948f2ec210642fa6021450d40dbc8ce924ad 100644 (file)
@@ -1,3 +1,16 @@
+2006-01-05  Jackson Harper  <jackson@ximian.com>
+
+       * AsyncMethodData.cs: Check if the call is complete before doing a WaitOne
+       * AsyncMethodResult.cs: We no longer use a WeakReference for the
+       AsyncMethodResult, this is because we ALWAYS want the
+       ManualResetEvent to get set.
+       * Control.cs: When disposing use an async invoke to call shutdown
+       code, so that thigns don't block on the finalizer thread.  Also
+       check if we even have a message loop before trying to send
+       messages, if we don't then don't bother sending messages.
+       - No more weak references for async methods
+       * XplatUIDriver.cs: No more weak references for async methods.
+
 2006-01-04  Alexander Olk  <alex.olk@googlemail.com>
 
        * FontDialog.cs: Fix, don't throw an exception if FontFamily.Families
index 89786d5d0542df3265cc3012537d87d9331c569c..221d2481d5009ff1a8f185f18daef139eb75514a 100644 (file)
@@ -745,8 +745,10 @@ namespace System.Windows.Forms
                        }
 
                        if (this.InvokeRequired) {
-                               this.InvokeInternal(new MethodInvoker(DestroyHandle), true);
-                               this.InvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
+                               if (Application.MessageLoop) {
+                                       this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
+                                       this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
+                               }
                        } else {
                                DestroyHandle();
                                controls.Remove(this);
@@ -798,7 +800,7 @@ namespace System.Windows.Forms
 
                        data.Method = method;
                        data.Args = args;
-                       data.Result = new WeakReference (result);
+                       data.Result = result;
 
 #if NET_2_0
                        if (!ExecutionContext.IsFlowSuppressed ()) {
index 9e7b88607a3215552e3fdcadcf4041b49a62193a..83d820ac6ab88172a775e3dea7d9362d427d4115 100644 (file)
@@ -267,6 +267,7 @@ namespace System.Windows.Forms {
                internal static void ExecuteClientMessage (GCHandle gchandle) {
                        AsyncMethodData data = (AsyncMethodData) gchandle.Target;
                        CompressedStack original = null;
+                       
 #if !MWF_ON_MSRUNTIME
                        // Stack is non-null only if the security manager is active
                        if (data.Stack != null) {
@@ -276,12 +277,9 @@ namespace System.Windows.Forms {
 #endif
 
                        try {
-                               AsyncMethodResult result = data.Result.Target as AsyncMethodResult;
+                               AsyncMethodResult result = data.Result;
                                object ret = data.Method.DynamicInvoke (data.Args);
-
-                               if (result != null) {
-                                       result.Complete (ret);
-                               }
+                               result.Complete (ret);
                        }
                        finally {
 #if !MWF_ON_MSRUNTIME