如何制作Process.Start阻塞调用?

Dex*_*ers 1 c# process blocking

我有一个调用Process.Start()运行第三方exe.我需要处理这个可执行文件的输出文件,所以我想要阻止对Process.Start()的调用.

是否可以将此呼叫更改为阻止呼叫?

Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
Run Code Online (Sandbox Code Playgroud)

Der*_*k W 10

Process.WaitForExit()就是你要找的.

指示Process组件无限期地等待关联进程退出.

你会像这样使用它:

Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
sampleProcess.WaitForExit(); // Will wait indefinitely until the process exits
Run Code Online (Sandbox Code Playgroud)