Wait until a process ends

NLV picture NLV · Jun 30, 2010 · Viewed 245k times · Source

I've an application which does

Process.Start()

to start another application 'ABC'. I want to wait till that application ends (process dies) and continue my execution. How can I do it?

There may be multiple instances of the application 'ABC' running at the same time.

Answer

Noldorin picture Noldorin · Jun 30, 2010

I think you just want this:

var process = Process.Start(...);
process.WaitForExit();

See the MSDN page for the method. It also has an overload where you can specify the timeout, so you're not potentially waiting forever.