internal class AsyncMethodResult : IAsyncResult {
- private Mutex handle;
+ private ManualResetEvent handle;
private object state;
private bool completed;
private object return_value;
public AsyncMethodResult ()
{
- handle = new Mutex ();
+ handle = new ManualResetEvent (false);
}
public virtual WaitHandle AsyncWaitHandle {
public object EndInvoke ()
{
+ lock (this) {
+ if (completed)
+ return return_value;
+ }
handle.WaitOne ();
return return_value;
}
lock (this) {
completed = true;
return_value = result;
- handle.ReleaseMutex ();
+ handle.Set ();
}
}
}