コード例 #1
0
            /// <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);
            }
コード例 #2
0
            private async Task <bool> ValidateUpgradeAsync(Task <bool> upgradeTask, TimeSpan?timeout)
            {
                var succeeded = await upgradeTask.ConfigureAwait(false);

                DistributedLockHelpers.ValidateTryAcquireResult(succeeded, timeout);
                return(succeeded);
            }
コード例 #3
0
        /// <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);
        }