Process.Exited event not firing

Process.Exited event not firing

I thought I'd share a quick tidbit of knowledge that just caused me a few minutes of frustration. The EnableRaisingEvents property must be set to true before the Exited event will be fired.

Process p = new Process();
p.StartInfo = new StartInfo();
p.StartInfo.FileName = "myExecutable.exe";

//required to receive exited event
p.EnabledRaisingEvents = true;

p.Exited += ProcessExited;

Aaron
04/08/2010 - 18:09

Wow, thanks! I solved the problem in 1 minute after finding this with a google search. :-D
--Aaron

reply

Anonymous
05/27/2010 - 22:34

For some reason, in Windows 7, when I use the taskbar to close some applications, the exited event does not fire. If I close the same application via the red window close button, then the event fires.

Any ideas?

reply

Atul
09/21/2010 - 06:53

Thanks a lot. This came in real handy

reply

Add Comment

Put code snippets inside language tags:
[language] [/language]

Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]

See here for supported languages.

Javascript must be enabled to submit anonymous comments - or you can login.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.