Пример #1
0
        public async Task AcquireWriteAsync(
            TimeSpan?timeout,
            CancellationToken cancellationToken)
        {
            int timeoutMs    = TimeoutHelper.GetTimeSpanInMilliseconds(timeout ?? TimeoutHelper.DefaultLockTimeout);
            var lockAcquired = await this.AcquireWriteLockAsync(timeoutMs, cancellationToken).ConfigureAwait(false);

            if (!lockAcquired)
            {
                throw new TimeoutException(SR.PrimeLockThrows_LockTimeout);
            }
        }
Пример #2
0
        public async Task <bool> TryAcquireReadAsync(TimeSpan?timeout, CancellationToken cancellationToken)
        {
            int timeoutMs = TimeoutHelper.GetTimeSpanInMilliseconds(timeout ?? TimeoutHelper.DefaultLockTimeout);

            return(await this.AcquireReadLockAsync(timeoutMs, cancellationToken).ConfigureAwait(false));
        }