Skip to content

AcquireLockAsync Method ​

Definition ​

  • Namespace: JASE.Extensions
  • Assembly: JASE.Concurrency.dll

Overloads ​

NameDescription
ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, CancellationToken cancellationToken = null)Acquires a lock of the requested type asynchronously.
ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, int timeoutMs, CancellationToken cancellationToken = null)Acquires a lock of the requested type asynchronously, waiting at most timeoutMs.

ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, int timeoutMs, CancellationToken cancellationToken = null) ​

csharp
ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, int timeoutMs, CancellationToken cancellationToken = null)

Acquires a lock of the requested type asynchronously, waiting at most timeoutMs.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the wait.
lockThe lock instance.
timeoutMsMaximum wait in milliseconds. When zero or negative, LockEntranceTimeout is used.
typeThe lock type to acquire.

Returns ​

A disposable handle that releases the lock.

ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, CancellationToken cancellationToken = null) ​

csharp
ValueTask<LockHandle> AcquireLockAsync(AsyncReaderWriterLock lock, LockType type, CancellationToken cancellationToken = null)

Acquires a lock of the requested type asynchronously.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the wait.
lockThe lock instance.
typeThe lock type to acquire. UpgradableRead is not supported.

Returns ​

A disposable handle that releases the lock.