// NOTE: If WaitForExit() returns false, more output may be written,
{
// so we must synchronize access to the output StringBuilders.
processLifetimeTask.TrySetException(newInvalidOperationException($"Command {filename} {arguments} returned exit code {process.ExitCode}. Standard error: \"{errorBuilder.ToString()}\""));
}
WithOutputLock(
else
()=>
{
{
// Since the process has exited, no additional data will be written to either output buffer or error buffer, it's thread-safe to call ToString() on both outputBuilder and errorBuilder.
processLifetimeTask.TrySetException(newInvalidOperationException($"Command {filename} {arguments} returned exit code {process.ExitCode}. Standard error: \"{errorBuilder.ToString()}\""));