是否有任何事件告诉我进程正在等待输入?

时间:2012-11-08 16:38:11

标签: c# wpf process redirectstandardoutput

我正在通过像这样开始Process来处理Tex文件:

process p1 = new Process();
p1.StartInfo.FileName = "C:\\texlive\\2012\\bin\\win32\\pdflatex.exe";
p1.StartInfo.Arguments = FileName;
p1.consuleProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p1.consuleProcess.StartInfo.CreateNoWindow = true;
p1.consuleProcess.StartInfo.RedirectStandardOutput = true;
p1.consuleProcess.StartInfo.UseShellExecute = false;
p1.consuleProcess.StartInfo.RedirectStandardInput = true;
p1.Start();
p1.consuleProcess.BeginOutputReadLine();
p1.consuleProcess.OutputDataReceived += new DataReceivedEventHandler(p1_OutputDataReceived);

我通过处理 OutputDataReceived 事件在TextBox中显示输出字符串。

如果Tex文件中有错误,则应在 StandardInput 中写入一行。我认为当进程等待输入时,没有任何事件可以告诉我;所以我想,我可以检查 OutputDataReceived 事件以查看条件: e.Data ==“?”何时为真。但是,问题是 StandardInput 需要输入,就在使用 e.Data ==“?” OutputDataReceived 事件之前>

那么,我该怎么做才能看到进程何时等待输入?

感谢。

1 个答案:

答案 0 :(得分:0)

不确定这是不是你的意思,但你是不是喜欢

p1.WaitForInputIdle(NumberofMilisecondstoWait)

更新

也许是这样的

  public void test()
        {
            p1.OutputDataReceived += new DataReceivedEventHandler(p1_OutputDataReceived);
        }

        void p1_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            throw new NotImplementedException();
        }