ReaderWriterLockSlimExtensions
Ecng.Common
Provides IDisposable-scope extension methods for ReaderWriterLockSlim, replacing the verbose try { rw.EnterXxxLock(); ... } finally { rw.ExitXxxLock(); } pattern with a single using statement.
Methoden
ReadLock
public static Scope ReadLock(ReaderWriterLockSlim rw)
result = ReaderWriterLockSlimExtensions.ReadLock(rw)
Enters in read mode and returns a scope that exits the read lock once on dispose.
- rw
- Lock to enter.
Rückgabe: Disposable scope tied to the read mode of .
UpgradeableReadLock
public static Scope UpgradeableReadLock(ReaderWriterLockSlim rw)
result = ReaderWriterLockSlimExtensions.UpgradeableReadLock(rw)
Enters in upgradeable read mode and returns a scope that exits the upgradeable read lock once on dispose.
- rw
- Lock to enter.
Rückgabe: Disposable scope tied to the upgradeable read mode of .
WriteLock
public static Scope WriteLock(ReaderWriterLockSlim rw)
result = ReaderWriterLockSlimExtensions.WriteLock(rw)
Enters in write mode and returns a scope that exits the write lock once on dispose.
- rw
- Lock to enter.
Rückgabe: Disposable scope tied to the write mode of .