我调用了运行第三方 exe 的 Process.Start()
。我需要处理此可执行文件的输出文件,因此我希望阻塞对 Process.Start() 的调用。
是否可以将此调用更改为阻塞调用?
Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
最佳答案
Process.WaitForExit()正是您要找的。p>
Instructs the Process component to wait indefinitely for the associated process to exit.
你会像这样使用它:
Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
sampleProcess.WaitForExit(); // Will wait indefinitely until the process exits
关于c# - 如何进行 Process.Start 阻塞调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21394660/