문제

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