Class AsyncLock
A lock that allows for async based operations and returns a IDisposable which allows for unlocking.
- Inheritance
-
Async
Lock
- Implements
- Extension Methods
Remarks
Straight-up thieved from http://www.hanselman.com/blog/ComparingTwoTechniquesInNETAsynchronousCoordinationPrimitives.aspx and all credit to that article.
Constructors
AsyncLock()
Initializes a new instance of the Async
Methods
Dispose()
LockAsync(CancellationToken)
Performs a lock which will be either released when the cancellation token is cancelled, or the returned disposable is disposed.
Parameters
cancellationToken
CancellationToken A cancellation token which allows for release of the lock.
Returns
- Task<IDisposable>
A disposable which when Disposed will release the lock.