public void UpgradeToWriteLock() { if (write) { throw new InvalidOperationException("Lock already upgraded"); } // it is important that these never throw exceptions, they shouldn't ever // because Interlocked should never throw locker.WaitForWriteLock(); write = true; }
public ReaderWriterLockAsyncLocker(ReaderWriterLockAsync locker, bool write) { this.locker = locker; this.write = write; // it is important that these never throw exceptions, they shouldn't ever // because Interlocked should never throw locker.WaitForReadLock(); if (write) { locker.WaitForWriteLock(); } }