Reputation: 1155
When running Process.Start in a .NET application we wait until the process has started or failed rather than continuing in the calling program/method - is this correct?
Upvotes: 1
Views: 1066
Reputation: 16107
Have a read at http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx. Process.Start will return once the process is launched. If you want to wait until the process has exited, then you need to call WaitForExit.
Be aware that there are potential deadlock issues if you are redirecting StandardOutput and StandardError and calling WaitForExit. If you are not reading the streams for StandardOutput and StandardError then the buffer can fill and the process will block. Hence WaitForExit will never return. The usual solution is to put calls to ReadToEnd on the StandardOutput and StandardError in threadpool threads and call WaitForExit on the main thread.
Upvotes: 2
Reputation: 37830
Once the the application launched by Process.Start has began (or failed to launch) then control returns to your application.
Upvotes: 0