This is a library for .NET that allows you to invoke an external process, and expose its output as an async stream in C# 8.0.
using Toolbelt.Diagnostics;
...
using var process = await XProcess.Start("foo.exe").WaitForExitAsync();
if (process.ExitCode != 0) throw new Exception(process.Output);
using Toolbelt.Diagnostics;
...
using var process = XProcess.Start("foo.exe");
await foreach(string output in process.GetOutputAsyncStream())
{
// do something.
}
// When reaching here, it means the process was exited.
using Toolbelt.Diagnostics;
...
using var process = XProcess.Start("foo.exe");
var found = await process.WaitForOutputAsync(str => str.Contains("Now listening on:"), millsecondsTimeout: 5000);
// If the "found" is false, it means the process had not outputed "Now listening on:" in 5 sec.
Release notes is here.