Show / Hide Table of Contents

Class AsyncLockAcquisition

Provides a set of methods to acquire different types of asynchronous lock.

Inheritance
object
AsyncLockAcquisition
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public static class AsyncLockAcquisition

Methods

| Edit this page View Source

AcquireLockAsync(object, CancellationToken)

Acquires exclusive lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireLockAsync(object obj, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireLockAsync(object, TimeSpan, CancellationToken)

Acquires exclusive lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireLockAsync(object obj, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

TimeoutException

The lock cannot be acquired during the specified amount of time.

| Edit this page View Source

AcquireReadLockAsync(object, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireReadLockAsync(object obj, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireReadLockAsync(object, TimeSpan, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireReadLockAsync(object obj, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
TimeoutException

The lock cannot be acquired during the specified amount of time.

OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireWriteLockAsync(object, bool, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireWriteLockAsync(object obj, bool upgrade, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

bool upgrade

true to upgrade from read lock; otherwise, false.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireWriteLockAsync(object, bool, TimeSpan, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireWriteLockAsync(object obj, bool upgrade, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

bool upgrade

true to upgrade from read lock; otherwise, false.

TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
TimeoutException

The lock cannot be acquired during the specified amount of time.

OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireWriteLockAsync(object, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireWriteLockAsync(object obj, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AcquireWriteLockAsync(object, TimeSpan, CancellationToken)

Acquires reader lock associated with the given object.

Declaration
public static ValueTask<AsyncLock.Holder> AcquireWriteLockAsync(object obj, TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
object obj

The object to be locked.

TimeSpan timeout

The interval to wait for the lock.

CancellationToken token

The token that can be used to abort acquisition operation.

Returns
Type Description
ValueTask<AsyncLock.Holder>

The acquired lock holder.

Exceptions
Type Condition
TimeoutException

The lock cannot be acquired during the specified amount of time.

OperationCanceledException

The operation has been canceled.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾