public bool Set() { lock (this) { CheckDisposed(); return(NativeEventCalls.SetEvent(SafeWaitHandle)); } }
public bool Dispose(WaitHandle notifyObject) { if (notifyObject == null) { throw new ArgumentNullException("notifyObject"); } Dispose(); NativeEventCalls.SetEvent(notifyObject.SafeWaitHandle); return(true); }
internal void Wait(object state) { bool release = false; try { _waitObject.SafeWaitHandle.DangerousAddRef(ref release); try { WaitHandle[] waits = new WaitHandle[] { _waitObject, _cancelEvent }; do { int signal = WaitHandle.WaitAny(waits, _timeout, false); if (!_unregistered) { lock (this) { _callsInProcess++; } ThreadPool.QueueUserWorkItem(new WaitCallback(DoCallBack), (signal == WaitHandle.WaitTimeout)); } } while (!_unregistered && !_executeOnlyOnce); } catch { } lock (this) { _unregistered = true; if (_callsInProcess == 0 && _finalEvent != null) { #if NETCORE throw new NotImplementedException(); #else NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle); _finalEvent = null; #endif } } } catch (ObjectDisposedException) { // Can happen if we called Unregister before we had time to execute Wait if (release) { throw; } } finally { if (release) { _waitObject.SafeWaitHandle.DangerousRelease(); } } }
[System.Security.SecuritySafeCritical] // auto-generated public bool Set() { #if MONO var res = NativeEventCalls.SetEvent(safeWaitHandle); #else bool res = Win32Native.SetEvent(safeWaitHandle); #endif if (!res) #if MONO { throw new IOException(); } #else { __Error.WinIOError(); } #endif return(res); }
private void DoCallBack(object timedOut) { if (_callback != null) { try { _callback(_state, (bool)timedOut); } catch {} } lock (this) { _callsInProcess--; if (_unregistered && _callsInProcess == 0 && _finalEvent != null) { NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle); } } }
private void DoCallBack(object timedOut) { try { if (_callback != null) { _callback(_state, (bool)timedOut); } } finally { lock (this) { _callsInProcess--; if (_unregistered && _callsInProcess == 0 && _finalEvent != null) #if NETCORE { EventWaitHandle.Set(_finalEvent.SafeWaitHandle); } #else { NativeEventCalls.SetEvent(_finalEvent.SafeWaitHandle); } #endif } } }