Console.In.ReadLineAsync(CancellationToken)
Anyone know a good fix for this? ReadLineAsync is not being cancelled until I feed my terminal a newline character
c#
var cts = new CancellationTokenSource();
Console.CancelKeyPress += (s, e) =>
{
Console.WriteLine("Cancelling!");
cts.Cancel();
e.Cancel = true;
};
Console.WriteLine("Enter commands...");
while (!cts.IsCancellationRequested)
{
await Console.In.ReadLineAsync(cts.Token).ConfigureAwait(false);
}
Console.WriteLine("Bye...");