コード例 #1
0
        public async Task SignalAndWaitFromTwo()
        {
            var evt = new AsyncCountdownEvent(2);

            var first = evt.SignalAndWaitAsync();

            Assert.False(first.IsCompleted);

            var second = evt.SignalAndWaitAsync();
            await Task.WhenAll(first, second);
        }
コード例 #2
0
        public void SignalAndWaitSynchronousBlockDoesNotHang()
        {
            SynchronizationContext.SetSynchronizationContext(SingleThreadedSynchronizationContext.New());
            var evt = new AsyncCountdownEvent(1);

            Assert.True(evt.SignalAndWaitAsync().Wait(AsyncDelay), "Hang");
        }
コード例 #3
0
        public void SignalAndWaitAsyncReturnsFaultedTaskOnError()
        {
            var evt    = new AsyncCountdownEvent(0);
            var result = evt.SignalAndWaitAsync();

            Assert.True(result.IsFaulted);
            Assert.IsType(typeof(InvalidOperationException), result.Exception.InnerException);
        }
コード例 #4
0
 public async Task SignalAndWaitFromOne()
 {
     var evt = new AsyncCountdownEvent(1);
     await evt.SignalAndWaitAsync();
 }