尝试调用“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();
}
“死锁异常”——错误有时会发生,但并非总是如此。