/// <summary> /// Acquires the lock asynchronously, failing with <see cref="TimeoutException"/> if the wait times out /// <code> /// using (await myLock.AcquireAsync(...)) /// { /// // we have the lock /// } /// // dispose releases the lock /// </code> /// </summary> /// <param name="timeout">How long to wait before giving up on acquiring the lock. Defaults to <see cref="Timeout.InfiniteTimeSpan"/></param> /// <param name="cancellationToken">Specifies a token by which the wait can be canceled</param> /// <returns>An <see cref="IDisposable"/> "handle" which can be used to release the lock</returns> public Task <IDisposable> AcquireAsync(TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken)) { return(DistributedLockHelpers.AcquireAsync(this, timeout, cancellationToken)); }