开发者

atexit, exit delegate in c#

开发者 https://www.devze.com 2022-12-10 19:47 出处:网络
I开发者_JS百科n 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#?

I开发者_JS百科n 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?


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


Maybe the answers to this may help you:

  • How do I trap ctrl-c in a C# console app


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消