Process.Exited doesn't throw?

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
 
C

Chris Taylor

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
 
M

Marc Lewandowski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top