我正在通过启动一个 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 事件之前>
那么,我该如何查看进程何时正在等待输入?
谢谢。
最佳答案
不确定这是不是你的意思,但你是不是在寻找类似的东西
p1.WaitForInputIdle(NumberofMilisecondstoWait)
更新:
也许是这样的
public void test()
{
p1.OutputDataReceived += new DataReceivedEventHandler(p1_OutputDataReceived);
}
void p1_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
throw new NotImplementedException();
}
关于c# - 是否有任何事件告诉我进程正在等待输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13293470/