views:

38

answers:

1

Say I have created a process using Process.Start();.

How would I tell if it had been closed/terminated, without freezing the application.

In CSharp, of course.

Thanks!

+2  A: 

Try the following

Process p = Process.Start(...);
p.Exited += OnProcessExited;

private void OnProcessExited(object sender, EventArgs e) {
  // Put code here
}

There is one catch to this code though. It's possible for the Process to exit before the event handler is attached. So you may not receive this event for a Process which exits quickly.

JaredPar
One issue, it does not seem to work when you create a process, set arguments and filename, and then call PROCESSNAME.Start(); Any help?
Ruirize