I have a call to Process.Start() which runs a third party exe. I need to process the output files of this executable so I want the call to Process.Start() to be blocking.

Is it possible to change this call to a blocking call?

Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
有帮助吗?

解决方案

Process.WaitForExit() is what you are looking for.

Instructs the Process component to wait indefinitely for the associated process to exit.

You would use it like this:

Process sampleProcess= new Process();
sampleProcess.StartInfo = sampleProcessInfoObject;
sampleProcess.Start();
sampleProcess.WaitForExit(); // Will wait indefinitely until the process exits
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top