新しく作成されたプロセスの stdoutput を使用する MSDN の例から:
// This is the code for the base process
Process myProcess = new Process();
// Start a new instance of this program but specify the 'spawned' version.
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(args[0], "spawn");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
// Read the standard output of the spawned process.
string myString = myStreamReader.ReadLine();
Console.WriteLine(myString);
myProcess.WaitForExit();
myProcess.Close();
myStreamReader.ReadLine() の代わりに myStreamReader.ReadToEnd() を使用している場合でも、myProcess.WaitForExit() を使用しますか? または、ReadToEnd() はプロセスが終了するまで待機しますか?