I have the following application in C#. What I was expecting was that it would open calc.exe, wait for me to close it manually (console would hang), and then it would finally exit. But it opens calc.exe and exits (while calc is still open). What am I missing?
class Program
{
static void Main(string[] args)
{
Process p2 = new Process();
p2.StartInfo.UseShellExecute = false;
p2.StartInfo.RedirectStandardError = true;
p2.StartInfo.FileName = "calc.exe";
p2.Start();
string error = p2.StandardError.ReadToEnd();
p2.WaitForExit();
Console.WriteLine("done");
}
}
code copied from here.