internal WaitForEventsAsyncResult(InstanceHandle handle, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.handle = handle; this.timeout = timeout; if (this.timeout != TimeSpan.Zero && this.timeout != TimeSpan.MaxValue) { this.timer = new IOThreadTimer(WaitForEventsAsyncResult.timeoutCallback, this, false); } List <InstancePersistenceEvent> existingReadyEvents = this.handle.StartWaiting(this, this.timer, this.timeout); if (existingReadyEvents == null) { if (this.timeout == TimeSpan.Zero) { this.handle.CancelWaiting(this); throw Fx.Exception.AsError(new TimeoutException(SRCore.WaitForEventsTimedOut(TimeSpan.Zero))); } } else { this.readyEvents = existingReadyEvents; Complete(true); } }
private static void OnTimeout(object state) { InstanceHandle.WaitForEventsAsyncResult result = (InstanceHandle.WaitForEventsAsyncResult)state; if (result.handle.CancelWaiting(result)) { result.Complete(false, new TimeoutException(SRCore.WaitForEventsTimedOut(result.timeout))); } }
static void OnTimeout(object state) { WaitForEventsAsyncResult thisPtr = (WaitForEventsAsyncResult)state; if (thisPtr.handle.CancelWaiting(thisPtr)) { thisPtr.Complete(false, new TimeoutException(SRCore.WaitForEventsTimedOut(thisPtr.timeout))); } }