internal class AsyncMethodData {
public Delegate Method;
public object [] Args;
- public WeakReference Result;
+ public AsyncMethodResult Result;
#if NET_2_0
public ExecutionContext Context;
#else
public object EndInvoke ()
{
+ lock (this) {
+ if (completed)
+ return return_value;
+ }
handle.WaitOne ();
return return_value;
}
+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
}
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);
data.Method = method;
data.Args = args;
- data.Result = new WeakReference (result);
+ data.Result = result;
#if NET_2_0
if (!ExecutionContext.IsFlowSuppressed ()) {
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) {
#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