Exemplo n.º 1
0
        public async Task EnterAsync_WhenCompleted_LockIsAcquired()
        {
            await _mutex.EnterAsync(Key, CancellationToken.None);

            using (var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(3)))
            {
                await Assert.ThrowsAsync <OperationCanceledException>(() => _mutex.EnterAsync(Key, cancellationTokenSource.Token));
            }

            await _mutex.ExitAsync(Key);
        }