On my system there is an application (App.exe) that runs, but sometimes it terminates (gracefully and expectantly). At the same time I have another application that, when App.exe is stopped, needs to perform certain tasks. So I need a way to monitor App.exe from my application.
Something like the following is what I am trying to accomplish
1 2 3
|
If (App.exe is running wait 360 seconds for it to terminate)
if (App.exe is not running anymore)
do the work I need to do when App.exe is NOT running
|
So, they KEY is:
- how do I evaluate if App.exe is running
- how do I wait 360 seconds for it to close (if it is still running)
Now this is not very difficult if my Application is the onw that started/spwaned App.exe (using CreateProcess and WaitForExit stuff), but in this case I am not the controlling agent ... so how do I monitor to see if App.exe is still running and consequently wait (for period of time X) for it to end before doing something specific?
Any hints, help, or recommendantions would be much appreciated.
Thanks,