I read that this portion of code can cause deadlock:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
Because
A deadlock condition can result if the parent process calls
p.WaitForExit
beforep.StandardOutput.ReadToEnd
and the child process writes enough text to fill the redirected stream. The parent process would wait indefinitely for the child process to exit. The child process would wait indefinitely for the parent to read from the full StandardOutput stream.
But I don't quite why. I mean, in this case here, what's the parent process, and what's the child?