public void Dispose() { if (_lockTaken) { _rwLock.ExitReadLock(); } #if DEBUG LockDebug.RemoveReader(_rwLock, _st); #endif }
public ReadContext(ReaderWriterLockSlim rwLock, int timeout) { _rwLock = rwLock; _lockTaken = _rwLock.TryEnterReadLock(timeout); #if DEBUG _st = new StackTrace(); if (!_lockTaken) { UPnPConfiguration.LOGGER.Warn("UPnP: Could not enter read lock. Caller: " + _st); } else { LockDebug.AddReader(_rwLock, _st); } #else if (!_lockTaken) { UPnPConfiguration.LOGGER.Warn("UPnP: Could not enter read lock. Caller: " + new StackTrace()); } #endif }