public static async Task Run() { IBuffer <string> buff = new ChannelsBuffer <string>(); var cts = new CancellationTokenSource(); var reader = ReadAndPrint(buff, cts.Token); while (!cts.IsCancellationRequested) { var str = Console.ReadLine(); switch (str) { case "quit": cts.Cancel(); break; case "exit": buff.Dispose(); cts.Cancel(); break; default: await buff.Add(str); break; } } await reader; }
public static async Task Run() { IBuffer <Message> buff = new ChannelsBuffer <Message>(); var read = ReadAndPrint(buff); await buff.Add(new HelloMessage { Message = "Hello" }); buff.Dispose(); await read; }