DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="0.3.0" />

 LockAcquisition

public static class LockAcquisition
Provides a set of methods to acquire different types of lock.
public static Lock Lock<T>(this T obj)

Acquires exclusive lock for the specified object.

public static Lock Lock<T>(this T obj, TimeSpan timeout)

Acquires monitor lock.

public static Lock Lock(this SemaphoreSlim semaphore)

Blocks the current thread until it can enter the semaphore.

public static Lock Lock(this SemaphoreSlim semaphore, TimeSpan timeout)

Blocks the current thread until it can enter the semaphore.

public static Lock ReadLock<T>(this T obj)

Acquires read lock for the specified object.

public static Lock ReadLock<T>(this T obj, TimeSpan timeout)

Acquires read lock for the specified object.

public static Lock ReadLock(this ReaderWriterLockSlim rwLock)

Acquires read lock.

public static Lock ReadLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires read lock.

public static Lock UpgradableReadLock<T>(this T obj)

Acquires upgradable read lock for the specified object.

public static Lock UpgradableReadLock<T>(this T obj, TimeSpan timeout)

Acquires upgradable read lock for the specified object.

public static Lock UpgradableReadLock(this ReaderWriterLockSlim rwLock)

Acquires upgradable read lock.

public static Lock UpgradableReadLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires upgradable read lock.

public static Lock WriteLock<T>(this T obj)

Acquires write lock for the specified object.

public static Lock WriteLock<T>(this T obj, TimeSpan timeout)

Acquires write lock for the specified object.

public static Lock WriteLock(this ReaderWriterLockSlim rwLock)

Acquires write lock.

public static Lock WriteLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires write lock.