How do a trap a process kill attempt?

  • Thread starter Thread starter Peter Steele
  • Start date Start date
P

Peter Steele

I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be done?
 
Peter said:
I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be done?
I think you worry too much, as long as you do the normal cleanup at the
program exit, it should be fine.

Just imagine how could you trap when people shut down the computer, or
power off :-)

John
 
John said:
I think you worry too much, as long as you do the normal cleanup at the
program exit, it should be fine.

Just imagine how could you trap when people shut down the computer, or
power off :-)

John
You should try brushing up on your event listeners
 
This is definitely not worrying too much. It is essential that this
application make every best effort to close down cleanly. If someone shuts
the power off, then clearly there's nothing that can be done...
 
Subscribe to the AppDomain.CurrentDomain.ProcessExit event - this gets fired
when the application is terminating cleanly and while all system components,
appdomains, etc. are still functional.
 

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

Back
Top