Show / Hide Table of Contents

Class AsyncExclusiveLock

Represents asynchronous mutually exclusive lock.

Inheritance
Object
Disposable
QueuedSynchronizer
AsyncExclusiveLock
Implements
IAsyncDisposable
Inherited Members
QueuedSynchronizer.TrackSuspendedCallers(Nullable<Func<Object>>)
QueuedSynchronizer.SetCallerInformation(Object)
QueuedSynchronizer.GetSuspendedCallers()
QueuedSynchronizer.LockContentionCounter
QueuedSynchronizer.LockDurationCounter
QueuedSynchronizer.CancelSuspendedCallers(CancellationToken)
QueuedSynchronizer.Dispose(Boolean)
QueuedSynchronizer.Dispose(Nullable<Exception>)
QueuedSynchronizer.DisposeAsyncCore()
QueuedSynchronizer.DisposeAsync()
Disposable.IsDisposed
Disposable.ThrowIfDisposed()
Disposable.DisposedTask
Disposable.GetDisposedTask<T>()
Disposable.TrySetDisposedException<T>(TaskCompletionSource<T>)
Disposable.TrySetDisposedException(TaskCompletionSource)
Disposable.Dispose()
Disposable.Dispose(IEnumerable<Nullable<IDisposable>>)
Disposable.DisposeAsync(IEnumerable<Nullable<IAsyncDisposable>>)
Disposable.Dispose(Nullable<IDisposable>[])
Disposable.DisposeAsync(Nullable<IAsyncDisposable>[])
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncExclusiveLock : QueuedSynchronizer

Constructors

| Improve this Doc View Source

AsyncExclusiveLock()

Initializes a new asynchronous exclusive lock.

Declaration
public AsyncExclusiveLock()
| Improve this Doc View Source

AsyncExclusiveLock(Int32)

Initializes a new asynchronous exclusive lock.

Declaration
public AsyncExclusiveLock(int concurrencyLevel)
Parameters
Type Name Description
Int32 concurrencyLevel

The expected number of concurrent flows.

Properties

| Improve this Doc View Source

IsLockHeld

Indicates that exclusive lock taken.

Declaration
public bool IsLockHeld { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

AcquireAsync(CancellationToken)

Enters the lock in exclusive mode asynchronously.

Declaration
public ValueTask AcquireAsync(CancellationToken token = null)
Parameters
Type Name Description
CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
ValueTask

The task representing lock acquisition operation.

| Improve this Doc View Source

AcquireAsync(TimeSpan, CancellationToken)

Enters the lock in exclusive mode asynchronously.

Declaration
public ValueTask AcquireAsync(TimeSpan timeout, CancellationToken token = null)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
ValueTask

The task representing lock acquisition operation.

| Improve this Doc View Source

Release()

Releases previously acquired exclusive lock.

Declaration
public void Release()
| Improve this Doc View Source

TryAcquire()

Attempts to obtain exclusive lock synchronously without blocking caller thread.

Declaration
public bool TryAcquire()
Returns
Type Description
Boolean

true if lock is taken successfuly; otherwise, false.

| Improve this Doc View Source

TryAcquireAsync(TimeSpan, CancellationToken)

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

Declaration
public ValueTask<bool> TryAcquireAsync(TimeSpan timeout, CancellationToken token = null)
Parameters
Type Name Description
TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort lock acquisition.

Returns
Type Description
ValueTask<Boolean>

true if the caller entered exclusive mode; otherwise, false.

Implements

IAsyncDisposable

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.As<T>(T)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Supported by the .NET Foundation
☀
☾