I am processing a Tex file by starting a Process
like this one:
我正在处理一个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);
I display the output strings in a TextBox
by handling OutputDataReceived event.
我通过处理OutputDataReceived事件在文本框中显示输出字符串。
If there were an error in the Tex file, a line should be written in StandardInput. I think there is no event that can tell me, when the process is waiting for an input; So I thought, I can check OutputDataReceived event to see when the condition: e.Data == "?" is true. But, the problem is that the StandardInput needs an input, just before firing OutputDataReceived event with e.Data=="?"
如果Tex文件中有错误,应该用StandardInput编写一行。我认为没有任何事件可以告诉我,当进程在等待输入;所以我想,我可以检查OutputDataReceived事件,看看什么时候条件:e。数据= "?"是真的。但是,问题是StandardInput需要一个输入,就在用e.Data= "?"触发OutputDataReceived事件之前。
So, what can I do to see when the process is waiting for an input?
那么,当进程在等待输入时,我能做些什么呢?
thanks.
谢谢。
1 个解决方案
#1
0
Not sure if this is what you mean but are you after something like
不确定这是不是你的意思,但你是在追求类似的东西吗
p1.WaitForInputIdle(NumberofMilisecondstoWait)
Update:
更新:
Maybe something like this
也许是这样的
public void test()
{
p1.OutputDataReceived += new DataReceivedEventHandler(p1_OutputDataReceived);
}
void p1_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
throw new NotImplementedException();
}
#1
0
Not sure if this is what you mean but are you after something like
不确定这是不是你的意思,但你是在追求类似的东西吗
p1.WaitForInputIdle(NumberofMilisecondstoWait)
Update:
更新:
Maybe something like this
也许是这样的
public void test()
{
p1.OutputDataReceived += new DataReceivedEventHandler(p1_OutputDataReceived);
}
void p1_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
throw new NotImplementedException();
}