public async Task EnqueueThings(CancellationToken cancel) { Debug.WriteLine("ENQUEUE cancel? " + cancel.IsCancellationRequested); while (cancel.IsCancellationRequested == false) { var thingy = DateTime.Now.ToString(); await Task.Delay(250); Debug.WriteLine(thingy + " enqueued"); OutputText = "enqueing: " + thingy + " queue count: " + TestQueue.Count(); TestQueue.EnqueueSignalAwaiter(thingy); } }
public async Task DequeueThings(CancellationToken cancel) { Debug.WriteLine("DEQUEUE cancel? " + cancel.IsCancellationRequested); while (cancel.IsCancellationRequested == false) { string thingy = ""; if (TestQueue.TryPeekAwait(out thingy)) { await Task.Delay(50); TestQueue.TryDequeue(out thingy); OutputText = "dequeued: " + thingy + " queue count: " + TestQueue.Count(); Debug.WriteLine("dequeued: " + thingy); } if (TestQueue.Count() == 0) { Debug.WriteLine("cancel"); source2.Cancel(); } } }