internal bool Unregister(WaitHandle waitObject) { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { bool flag2 = false; do { if (Interlocked.CompareExchange(ref this.m_lock, 1, 0) == 0) { flag2 = true; try { if (this.ValidHandle()) { flag = RegisteredWaitHandleSafe.UnregisterWaitNative(this.GetHandle(), (waitObject == null) ? null : waitObject.SafeWaitHandle); if (flag) { if (this.bReleaseNeeded) { this.m_internalWaitObject.SafeWaitHandle.DangerousRelease(); this.bReleaseNeeded = false; } this.SetHandle(RegisteredWaitHandleSafe.InvalidHandle); this.m_internalWaitObject = null; GC.SuppressFinalize(this); } } } finally { this.m_lock = 0; } } Thread.SpinWait(1); }while (!flag2); } return(flag); }
internal RegisteredWaitHandle() { internalRegisteredWait = new RegisteredWaitHandleSafe(); }