Example #1
0
        public void Dispose_with_events_traces_event()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                queue.Dispose();

                Assert.True(inner.Disposed);
                listener.VerifyEvent(QueueEventId.QueueDispose, EventLevel.Informational, EventKeywords.None, id);
            }
        }
Example #2
0
        private static void Main(string[] args)
        {
            IInputQueue<int> queue = new InputQueueWithEvents<int>(new InputQueue<int>(), Guid.NewGuid(), QueueEventSource.Instance);
            using (CancellationTokenSource cts = new CancellationTokenSource())
            {
                Task enqueueTask = PrintException(EnqueueLoopAsync(queue, cts.Token));
                Task dequeueTask = PrintException(DequeueLoopAsync(queue, cts.Token));

                Console.WriteLine("Press ENTER to cancel.");
                Console.ReadLine();
                cts.Cancel();
                queue.Dispose();

                Task.WaitAll(enqueueTask, dequeueTask);
            }
        }