DotNext by Roman Sakno

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

 LockAcquisition

public static class LockAcquisition
Provides a set of methods to acquire different types of lock.
public static Holder AcquireLock(this SemaphoreSlim semaphore)

Blocks the current thread until it can enter the semaphore.

public static Holder AcquireLock(this SemaphoreSlim semaphore, TimeSpan timeout)

Blocks the current thread until it can enter the semaphore.

public static Holder AcquireReadLock(this ReaderWriterLockSlim rwLock)

Acquires read lock.

public static Holder AcquireReadLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires read lock.

public static Holder AcquireReadLock<T>(this T obj)

Acquires read lock for the specified object.

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

Acquires read lock for the specified object.

Acquires upgradeable read lock.

public static Holder AcquireUpgradeableReadLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires upgradeable read lock.

public static Holder AcquireUpgradeableReadLock<T>(this T obj)

Acquires upgradeable read lock for the specified object.

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

Acquires upgradeable read lock for the specified object.

public static Holder AcquireWriteLock(this ReaderWriterLockSlim rwLock)

Acquires write lock.

public static Holder AcquireWriteLock(this ReaderWriterLockSlim rwLock, TimeSpan timeout)

Acquires write lock.

public static Holder AcquireWriteLock<T>(this T obj)

Acquires write lock for the specified object.

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

Acquires write lock for the specified object.