Tutorial :atexit, exit delegate in c#



Question:

In c++ there is a function called atexit where you can register functions which should be run when the system exits. Are there any similar events in C#?

UPDATE: The AppDomain.ProcessExit doesn't seem to catch Ctrl-C or Ctrl-Break. Anyone knows anything about that?


Solution:1

You can check the ProcessExit and DomainUnload events of the AppDomain class.


Solution:2

Maybe the answers to this may help you:


Solution:3

There's the Application.ApplicationExit event if you've a WinForms application. For WPF there's Application.Exit.


Solution:4

If you're running a WinForms app you can add a listener to the Application.ApplicationExit event


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »