Exemplo n.º 1
0
        public void HandlesCancellation()
        {
            var asyncLock = new AsyncLock();
            var lockOne = asyncLock.LockAsync();

            var cts = new CancellationTokenSource();
            var lockTwo = asyncLock.LockAsync(cts.Token);

            Assert.True(lockOne.IsCompleted);
            Assert.Equal(TaskStatus.RanToCompletion, lockOne.Status);
            Assert.NotNull(lockOne.Result);

            Assert.False(lockTwo.IsCompleted);

            cts.Cancel();

            Assert.True(lockTwo.IsCompleted);
            Assert.True(lockTwo.IsCanceled);

            lockOne.Result.Dispose();
        }
Exemplo n.º 2
0
 internal Releaser(AsyncLock toRelease) { m_toRelease = toRelease; }
Exemplo n.º 3
0
 internal Releaser(AsyncLock toRelease)
 {
     _toRelease = toRelease;
 }