DotNext.Threading by Roman Sakno

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

 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.

public static Task<Holder> SuppressCancellation(this Task<Holder> result)

Suspends cancellation of lock acquisition and converts the canceled operation result into unsuccessfully acquired lock.

public static Task<Holder> SuppressDisposedState(this Task<Holder> result)

Suspends ObjectDisposedException if the target lock has been disposed.

Suspends cancellation of lock acquisition or ObjectDisposedException if the target lock has been disposed.