0
尝试调用“StandardOutput.ReadLine()”时应用程序挂起。应用程序冻结在“StandardOutput.ReadLine()”上。
代码:
ProcessStartInfo startInfo = new ProcessStartInfo("c:\\windows\\system32\\myTesting.exe");
String s = " ";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
Process p = Process.Start(startInfo);
p.StandardInput.WriteLine("list volume\n");
String f = "";
while (!p.StandardOutput.EndOfStream)
{
s = p.StandardOutput.ReadLine();
}
“死锁例外” 误差有时会发生,但并非总是如此。
http://stackoverflow.com/questions/2767496/standardoutput-endofstream-hangs – 2012-04-23 12:56:48