public int WaitForExitAndFinalize() { process.WaitForExit(); if (StdOut != null) { StdOut.Terminate(); } if (StdErr != null) { StdErr.Terminate(); } return(process.ExitCode); }