Switch to event driven reading from standard output and error

This commit is contained in:
Zeid Derhally
2019-02-15 14:08:31 -05:00
parent 9085e4a5db
commit d9d6aecdcb
+2 -4
View File
@@ -61,10 +61,8 @@ namespace Coverlet.Console
process.StartInfo.RedirectStandardError = true;
process.Start();
process.StandardOutput.ReadToEndAsync()
.ContinueWith(task => logger.LogInformation(task.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
process.StandardError.ReadToEndAsync()
.ContinueWith(task => logger.LogError(task.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
process.OutputDataReceived += (sender, eventArgs) => logger.LogInformation(eventArgs.Data);
process.ErrorDataReceived += (sender, eventArgs) => logger.LogError(eventArgs.Data);
process.WaitForExit();