What happens when you close the .NET console application?

Is a method like OnClosed(EventArgs e)

??

Update

Finished using the code from the following URL:

http://osdir.com/ml/windows.devel.dotnet.clr/2003-11/msg00214.html

+2


source to share


3 answers


Check out this article / post .



Basically, you are connecting to SetConsoleCtrlHandler and subscribing to events.

+1


source


No, because there is no message pump on the closed event.



However, the AppDomain is unloaded as the process is demolished, and this will start AppDomain.DomainUnloaded . You can use this to capture the event when the program shuts down.

+1


source


There is an event AppDomain.ProcessExit

that you can hook up an event handler to. Note that this is "time in a box"; by default, it allows execution for a maximum of 3 seconds, so you shouldn't be doing something for a long time there.

+1


source







All Articles