Class AsyncMutex
Represents a source of a fair asynchronous mutex primitive.
public sealed class AsyncMutex
- Inheritance
-
AsyncMutex
- Inherited Members
- Extension Methods
Remarks
Lock is not reentrant.
Constructors
AsyncMutex()
Creates a new AsyncMutex instance.
public AsyncMutex()
Properties
Participants
Returns the total number of lock participants, which includes current lock holder and all waiters.
public int Participants { get; }
Property Value
Methods
EnterAsync(CancellationToken)
Asynchronously acquires an exclusive lock from this mutex.
public ValueTask<AsyncMutexLock> EnterAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional CancellationToken that can be used to cancel pending mutex acquisition.
Returns
- ValueTask<AsyncMutexLock>
New ValueTask<TResult> instance which returns an AsyncMutexLock value.
Exceptions
- OperationCanceledException
When provided
cancellationTokenwas cancelled before the lock was acquired.
TrimExcess()
Attempts to discard unused resources.
public void TrimExcess()