title: process.startinfo.RedirectStandardOutput gives exception and process.waitforexit() hangs C# application
body: <p>using process i am getting an exception while using                  process.StartInfo.RedirectStandardOutput = true; 
  the exception is below 
  "StandardOut has not been redirected or the process hasn't started yet."</p>
  
  <p>i am using process.WaitForExit which hangs my application gui so i used process.StandardOutput.ReadToEnd(); before WaitForExit  as per MSDN but now my process run for infinite time and gives above exception in log file and GUI also hangs.</p>
  
  <pre><code>                Process process = new Process();
                  process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
  
  
                  string strArguments = ""; 
  
                  process.StartInfo.FileName = @"appname.bat";
                  process.StartInfo.Arguments = strArguments;
                  process.StartInfo.CreateNoWindow = true;
                  process.StartInfo.UseShellExecute = false;
                  process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                  process.StartInfo.RedirectStandardOutput = true;
                  process.StartInfo.RedirectStandardError = true;
  
                  process.Start();
  
  
                  string output = process.StandardOutput.ReadToEnd();
                  process.WaitForExit();
                  process.Close();
  </code></pre>
  
  <p>I am not getting where am i lacking or where is the error in the code... Even i have tried time out in waitforexit also but didn't get success.</p>