/// <summary> /// Upgrades to a WRITE lock synchronously. Not compatible with another WRITE lock or a UPGRADE lock /// </summary> public bool UpgradeToWriteLock(TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken)) { var succeeded = this.TryUpgradeToWriteLock(timeout ?? Timeout.InfiniteTimeSpan, cancellationToken); DistributedLockHelpers.ValidateTryAcquireResult(succeeded, timeout); return(succeeded); }
private async Task <bool> ValidateUpgradeAsync(Task <bool> upgradeTask, TimeSpan?timeout) { var succeeded = await upgradeTask.ConfigureAwait(false); DistributedLockHelpers.ValidateTryAcquireResult(succeeded, timeout); return(succeeded); }
/// <summary> /// Acquires a WRITE lock synchronously. Not compatible with another WRITE lock or a UPGRADE lock /// </summary> public IDisposable AcquireWriteLock(TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken)) { var handle = this.TryAcquireWriteLock(timeout ?? Timeout.InfiniteTimeSpan, cancellationToken); DistributedLockHelpers.ValidateTryAcquireResult(handle, timeout); return(handle); }