Threading Threading
Threading Threading
DocFX + Singulink = ♥

Search Results for

    Method EnterReadGuardAsync

    EnterReadGuardAsync(CancellationToken)

    Asynchronously enters the lock in read mode and returns a guard that leaves it when it is disposed.

    Declaration
    public ValueTask<AsyncReadGuard> EnterReadGuardAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A token that cancels the wait.

    Returns
    Type Description
    ValueTask<AsyncReadGuard>

    A task that contains a guard that entered the lock. The task has already completed, and nothing is allocated, when the lock is entered without waiting.

    Remarks

    The call waits while the lock is held in write mode and, unless the lock prefers readers, while a writer is waiting. The lock is not reentrant, so entering it again while the caller holds it can wait forever; see AsyncReadWriteLockPreference.

    Await the returned task once. For a time limit, use TryEnterReadGuardAsync(TimeSpan, CancellationToken). A limit put on the task itself, such as with WaitAsync, ends the await but not the wait, and a hold that the lock grants after it is never released.

    Exceptions
    Type Condition
    OperationCanceledException

    cancellationToken was canceled before the lock was entered.

    InvalidOperationException

    The lock is already held in read mode by the largest number of holds it can count (2^29).

    © Singulink. All rights reserved.