C# process.start, how do I know if the process ended?

MSDN System.Diagnostics.Process

If you want to know right now, you can check the HasExited property.

var isRunning = !process.HasExited;

If it’s a quick process, just wait for it.

process.WaitForExit();

If you’re starting one up in the background, subscribe to the Exited event after setting EnableRaisingEvents to true.

process.EnableRaisingEvents = true;
process.Exited += (sender, e) => {  /* do whatever */ };

Leave a Comment