Windows Mobile - Capture Application/Process Termination Event
I need to create Watchgog application that will keep track of main application. If my main application is crashed/closed/ended by any means, this watchdog application will activate it again.
I can do this by scanning running process at regular intervals, but this is resource intensive process. Can I get any notification when process is terminated (not Form Closing event, it 开发者_Go百科does not work when application crashes)?
Process class does give you such functions.
WaitForExit() (method) Instructs the Process component to wait indefinitely for the associated process to exit. Exited (event) Occurs when a process exits.
So you need to find your process only once and than in your watchdog use provided method or event.
精彩评论