Represents asynchronous mutually exclusive lock.
InheritanceAsyncExclusiveLock
Namespace: DotNext.Threading Assembly: DotNext.Threading.dll Syntaxpublic class AsyncExclusiveLock : QueuedSynchronizer, IDisposable, IAsyncDisposable
Constructors | Edit this page View Source AsyncExclusiveLock()
Initializes a new asynchronous exclusive lock.
Declarationpublic AsyncExclusiveLock()
| Edit this page View Source AsyncExclusiveLock(int)
Initializes a new asynchronous exclusive lock.
Declarationpublic AsyncExclusiveLock(int concurrencyLevel)
Parameters Type Name Description int concurrencyLevel
The expected number of concurrent flows.
Exceptions Properties | Edit this page View Source IsLockHeldIndicates that exclusive lock taken.
Declarationpublic bool IsLockHeld { get; }
Property Value Methods | Edit this page View Source AcquireAsync(CancellationToken)
Enters the lock in exclusive mode asynchronously.
Declarationpublic ValueTask AcquireAsync(CancellationToken token = default)
Parameters Type Name Description CancellationToken token
The token that can be used to abort lock acquisition.
Returns Type Description ValueTaskThe task representing lock acquisition operation.
Exceptions | Edit this page View Source AcquireAsync(TimeSpan, CancellationToken)Enters the lock in exclusive mode asynchronously.
Declarationpublic ValueTask AcquireAsync(TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description TimeSpan timeout
The interval to wait for the lock.
CancellationToken tokenThe token that can be used to abort lock acquisition.
Returns Type Description ValueTaskThe task representing lock acquisition operation.
Exceptions | Edit this page View Source Release()Releases previously acquired exclusive lock.
Declaration Exceptions | Edit this page View Source StealAsync(object?, CancellationToken)Interrupts all pending callers in the queue and acquires the lock.
Declarationpublic ValueTask StealAsync(object? reason = null, CancellationToken token = default)
Parameters Type Name Description object reason
The reason for lock steal.
CancellationToken tokenThe token that can be used to abort lock acquisition.
Returns Type Description ValueTaskThe task representing lock acquisition operation.
Exceptions See Also | Edit this page View Source StealAsync(object?, TimeSpan, CancellationToken)Interrupts all pending callers in the queue and acquires the lock.
Declarationpublic ValueTask StealAsync(object? reason, TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description object reason
The reason for lock steal.
TimeSpan timeoutThe interval to wait for the lock.
CancellationToken tokenThe token that can be used to abort lock acquisition.
Returns Type Description ValueTaskThe task representing lock acquisition operation.
Exceptions See Also | Edit this page View Source TryAcquire()Attempts to obtain exclusive lock synchronously without blocking caller thread.
Declaration Returns Type Description booltrue if lock is taken successfully; otherwise, false.
Exceptions | Edit this page View Source TryAcquire(TimeSpan, CancellationToken)Tries to acquire the lock synchronously.
Declarationpublic bool TryAcquire(TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description TimeSpan timeout
The interval to wait for the lock.
CancellationToken tokenThe token that can be used to cancel the operation.
Returns Type Description booltrue if the lock is acquired in timely manner; false if canceled or timed out.
Exceptions | Edit this page View Source TryAcquireAsync(TimeSpan, CancellationToken)Tries to enter the lock in exclusive mode asynchronously, with an optional time-out.
Declarationpublic ValueTask<bool> TryAcquireAsync(TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description TimeSpan timeout
The interval to wait for the lock.
CancellationToken tokenThe token that can be used to abort lock acquisition.
Returns Exceptions | Edit this page View Source TryStealAsync(object?, TimeSpan, CancellationToken)Interrupts all pending callers in the queue and acquires the lock.
Declarationpublic ValueTask<bool> TryStealAsync(object? reason, TimeSpan timeout, CancellationToken token = default)
Parameters Type Name Description object reason
The reason for lock steal.
TimeSpan timeoutThe interval to wait for the lock.
CancellationToken tokenThe token that can be used to abort lock acquisition.
Returns Exceptions See Also Implements Extension MethodsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4