【发布时间】:2014-02-02 19:47:56
【问题描述】:
我在我的软件中使用了 2 个不同的进程。在这两种情况下,我都会阅读流程输出并给用户一些关于它的指示。
ProcessStartInfo si = new ProcessStartInfo();
si.WindowStyle = ProcessWindowStyle.Hidden;
si.UseShellExecute = false;
si.CreateNoWindow = true;
si.RedirectStandardError = true;
si.RedirectStandardOutput = true;
si.FileName = "proc.exe";
si.Arguments = "some args";
Process p = new Process();
p.StartInfo = si;
p.ErrorDataReceived += cmd_Error;
p.OutputDataReceived += cmd_DataReceived;
p.EnableRaisingEvents = true;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
在第一种情况下,它完美无缺! 但在另一种情况下,该进程正在完成其工作,但只有终止事件被触发。 使用
运行时si.WindowStyle = ProcessWindowStyle.Normal
我看到这个过程有一个输出。
可能是什么问题?为什么没有触发输出事件?
【问题讨论】:
-
你是对的..我的意思是正常 - 已编辑
标签: c# .net command-line process stdout