Process.Exited doesn't throw?

  • Thread starter Thread starter Marc Lewandowski
  • Start date Start date
M

Marc Lewandowski

I am writing a Windows Service that monitors a running instance of another
(third-party) application by using the Process component. I set it up to
listen for the Process.Exited event, but that event never seems to be
raised.

I tested further, using a .dll that runs in NUnit (just a handy place to
test little hypotheses when I run into questions like this) and it still
wouldn't recognize the closure, cancelling, killing or otherwise ending an
application. I tried running on a different machine, and no dice. Is this
a known issue? I'm responding to this event just as I would any other
event. Is there something I missed?

I'd rather not do a timer loop that constantly checks the state of the
Process.

Thanks for your help.

-Marc
 
Hi,

Have you set the EnableRaisingEvents property of the Process to true. If you
do not then the event will not be raised.

Hope this helps

Chris Taylor
 
Ha! Well, thanks for pointing out the obvious.

Although, if any MSFT are reading, it would be nice if the Process.Exited
online docs mentioned this detail.

-Marc
 
Back
Top