public string RunCommand(CommandResult result) { var stdOut = result.StdOut.ReadToEnd(); result.RunningTask.Wait(); if (result.RunningTask.Result != 0) { throw new COMException("The execution of the command failed: \r\n" + result.StdErr.ReadToEnd(), result.RunningTask.Result); } return stdOut; }
public async Task<string> RunCommand(CommandResult result) { var stdOut = await result.StdOut.ReadToEndAsync().ConfigureAwait(false); var code = await result.RunningTask.ConfigureAwait(false); if (code != 0) { var error = await result.StdErr.ReadToEndAsync().ConfigureAwait(false); throw new CompileException("The execution of the command failed: \r\n" + error); } return stdOut; }