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.
 
Back
Top