Пример #1
0
        public void set_dequeue_signal()
        {
            var awaiter = new QueueAwaiter();

            awaiter.SetEnqueueSignal();

            Assert.True(awaiter.IsEnqueueSignalSet);
        }
Пример #2
0
        public async Task await_enqueue_signal_until_set_then_reset_signal()
        {
            var cts     = new CancellationTokenSource(5000);
            var awaiter = new QueueAwaiter();

            var waitTask = awaiter.AwaitEnqueueSignalAsync();

            Assert.False(awaiter.IsEnqueueSignalSet);

            awaiter.SetEnqueueSignal();

            await Task.WhenAny(new[] { waitTask, cts.Token.WaitHandle.AsTask() });

            if (cts.IsCancellationRequested)
            {
                throw new TimeoutException();
            }

            // Signal should auto reset.
            Assert.False(awaiter.IsEnqueueSignalSet);
        }