/// <summary> /// Releases rundown protection. /// </summary> public void Release() { int value; while (true) { value = _value; // Has the rundown already started? if ((value & RundownActive) != 0) { int newValue = Interlocked.Add(ref this._value, -RundownCountIncrement); // Are we the last out? Set the event if that's the case. if (newValue == RundownActive) { _wakeEvent.Set(); } return; } if (Interlocked.CompareExchange( ref this._value, value - RundownCountIncrement, value ) == value) { return; } } }
public void Set() { fe.Set(); }