<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />

Nito.AsyncEx.AsyncReaderWriterLock

public sealed class AsyncReaderWriterLock
A reader/writer lock that is compatible with async. Note that this lock is not recursive!
public int Id { get; }

Gets a semi-unique identifier for this asynchronous lock.

Creates a new async-compatible reader/writer lock.

public IDisposable ReaderLock(CancellationToken cancellationToken)

Synchronously acquires the lock as a reader. Returns a disposable that releases the lock when disposed. This method may block the calling thread.

Synchronously acquires the lock as a reader. Returns a disposable that releases the lock when disposed. This method may block the calling thread.

public AwaitableDisposable<IDisposable> ReaderLockAsync(CancellationToken cancellationToken)

Asynchronously acquires the lock as a reader. Returns a disposable that releases the lock when disposed.

public AwaitableDisposable<IDisposable> ReaderLockAsync()

Asynchronously acquires the lock as a reader. Returns a disposable that releases the lock when disposed.

public IDisposable WriterLock(CancellationToken cancellationToken)

Synchronously acquires the lock as a writer. Returns a disposable that releases the lock when disposed. This method may block the calling thread.

Asynchronously acquires the lock as a writer. Returns a disposable that releases the lock when disposed. This method may block the calling thread.

public AwaitableDisposable<IDisposable> WriterLockAsync(CancellationToken cancellationToken)

Asynchronously acquires the lock as a writer. Returns a disposable that releases the lock when disposed.

public AwaitableDisposable<IDisposable> WriterLockAsync()

Asynchronously acquires the lock as a writer. Returns a disposable that releases the lock when disposed.