static void Main(string[] args) { var preamble = new List <string> { "Hello there ... ctrl-c to quit", "------------------------------" }; SimpleSplitScreenConsole.InitConsole(preamble, OnShutDown); var cancellationToken = _tokenSource.Token; var tasks = new Task[] { Task.Factory.StartNew(Consume, cancellationToken), Task.Factory.StartNew(Produce, cancellationToken) }; try { Task.WaitAll(tasks); } catch (AggregateException aex) { SimpleSplitScreenConsole.OnResponse("Exception thrown: " + aex.Message); } }
private static void Consume() { while (!_tokenSource.IsCancellationRequested) { while (_messages.Count() > 0) { if (_messages.TryDequeue(out string message)) { SimpleSplitScreenConsole.OnResponse(message); } } Thread.Sleep(500); } }