I'm trying to do the following to prevent my console app do be stuck on Console.ReadLine()
during termination.
await Process.GetCurrentProcess().StandardInput.WriteLineAsync();
but I'm getting the InvalidOperationException
StandardIn is not redirected.
The attempt based on John's comment also fails with an exception Stream was not writable
:
using (var stdInStream = Console.OpenStandardInput())
using (var stdInWriter = new StreamWriter(stdInStream))
await stdInWriter.WriteLineAsync();
Is there an easy way to achieve this?