public bool ReleaseMutex() { _lock.Enter(); bool released; if (_ownerThreadId == Thread.CurrentThread.ManagedThreadId) { _enterCounter--; if (_enterCounter == 0) { _ownerThreadId = -1; _releaseSignal.Set(); } released = true; } else { released = false; } _lock.Exit(); return(released); }
public void Set() { _lock.Enter(); _isSet = true; _signal.Exit(); _lock.Exit(); }
public bool Wait() { _lock.Enter(); try { if (_ownerThreadId == Thread.CurrentThread.ManagedThreadId) { do { this.ReleaseImpl(); _lock.Exit(); _pulseSignal.WaitOne(); _lock.Enter(); }while (_isMultiPulse || (_isPulseHandled && !_isMultiPulse)); _isPulseHandled = true; this.CaptureImpl(); } else { throw new InvalidOperationException(); } } finally { _lock.Exit(); } return(true); }
public void WaitOne() { _spinlock.Enter(); if (_counter < _max) { _counter++; _spinlock.Exit(); } else { _spinlock.Exit(); _guard.WaitOne(); while (_counter == _max) { } _counter++; } }
public void WaitOne() { _signal.Enter(); _lock.Enter(); if (_isSet) { _signal.Exit(); } _lock.Exit(); }
public void WaitOne() { _signal.Enter(); }