public void Release(int units) { bool wasInterrupted; SyncUtils.EnterUninterruptibly(mon, out wasInterrupted); try { counter += units; grantAllAvailable(); } finally { Monitor.Exit(mon); if (wasInterrupted) { Thread.CurrentThread.Interrupt(); } } }
public void Set() { signaled = true; Interlocked.MemoryBarrier(); if (waiters != 0) { SyncUtils.EnterUninterruptibly(mon, out bool wasInterrupted); setVersion += 1; try { Monitor.PulseAll(mon); } finally { Monitor.Exit(mon); if (wasInterrupted) { Thread.CurrentThread.Interrupt(); } } } }