DotNext.Threading by .NET Foundation and Contributors

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

 AsyncLockAcquisition

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

Acquires exclusive lock associated with the given object.

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

Acquires exclusive lock associated with the given object.

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

Acquires reader lock associated with the given object.

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

Acquires reader lock associated with the given object.

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

Acquires writer lock associated with the given object.

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

Acquires reader lock associated with the given object.

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

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

public static ValueTask<Holder> SuppressDisposedState(this ValueTask<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.