AsyncLock class

A non-reentrant mutual exclusion lock that can be acquired asynchronously in a first-in first-out order. During testing, the lock is automatically replaced with a controlled mocked version.

public class AsyncLock

Public Members

name description
static Create() Creates a new mutual exclusion lock.
virtual AcquireAsync() Tries to acquire the lock asynchronously, and returns a task that completes when the lock has been acquired. The returned task contains a releaser that releases the lock when disposed. This is not a reentrant operation.
struct Releaser Releases the acquired AsyncLock when disposed.

Protected Members

name description
AsyncLock() Initializes a new instance of the AsyncLock class.
IsAcquired { get; set; } True if the lock has been acquired, else false.
readonly Awaiters Queue of tasks awaiting to acquire the lock.
virtual Release() Releases the lock.

See Also