Class AsyncLock
Provides a simple wrapper over a SemaphoreSlim to allow synchronization locking inside of async calls. Cannot be used recursively.
Inheritance
System.Object
AsyncLock
Namespace:Microsoft.SqlTools.ServiceLayer.Utility
Assembly:Microsoft.SqlTools.ServiceLayer.dll
Syntax
public class AsyncLock
Constructors
| Improve this Doc View SourceAsyncLock()
Initializes a new instance of the AsyncLock class.
Declaration
public AsyncLock()
Methods
| Improve this Doc View SourceLockAsync()
Locks
Declaration
public Task<IDisposable> LockAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IDisposable> | A task which has an IDisposable |
LockAsync(CancellationToken)
Obtains or waits for a lock which can be used to synchronize access to a resource. The wait may be cancelled with the given CancellationToken.
Declaration
public Task<IDisposable> LockAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | A CancellationToken which can be used to cancel the lock. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IDisposable> |