DotNext.Threading by Roman Sakno

<PackageReference Include="DotNext.Threading" Version="0.13.0" />

 AsyncLockAcquisition

public static class AsyncLockAcquisition
Provides a set of methods to acquire different types of asynchronous lock.
public static Task<Holder> AcquireLockAsync<T>(this T obj, TimeSpan timeout)

Acquires exclusive lock associated with the given object.

public static Task<Holder> AcquireLockAsync<T>(this T obj, CancellationToken token)

Acquires exclusive lock associated with the given object.

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

Acquires reader lock associated with the given object.

public static Task<Holder> AcquireReadLockAsync<T>(this T obj, CancellationToken token)

Acquires reader lock associated with the given object.

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

Acquires upgradeable lock associated with the given object.

public static Task<Holder> AcquireUpgradeableReadLockAsync<T>(this T obj, CancellationToken token)

Acquires upgradeable lock associated with the given object.

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

Acquires writer lock associated with the given object.

public static Task<Holder> AcquireWriteLockAsync<T>(this T obj, CancellationToken token)

Acquires reader lock associated with the given object.