DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="4.0.0-beta.8" />

 AsyncExclusiveLock

Represents asynchronous mutually exclusive lock.
public bool IsLockHeld { get; }

Indicates that exclusive lock taken.

public AsyncExclusiveLock(int concurrencyLevel)

Initializes a new asynchronous exclusive lock.

Initializes a new asynchronous exclusive lock.

public ValueTask AcquireAsync(TimeSpan timeout, CancellationToken token = default)

Enters the lock in exclusive mode asynchronously.

public ValueTask AcquireAsync(CancellationToken token = default)

Enters the lock in exclusive mode asynchronously.

public void Release()

Releases previously acquired exclusive lock.

public bool TryAcquire()

Attempts to obtain exclusive lock synchronously without blocking caller thread.

public ValueTask<bool> TryAcquireAsync(TimeSpan timeout, CancellationToken token = default)

Tries to enter the lock in exclusive mode asynchronously, with an optional time-out.