Reputation: 14362
Is a method such as OnClosed(EventArgs e)
called?
Update
Ended up using code from the following url:
http://osdir.com/ml/windows.devel.dotnet.clr/2003-11/msg00214.html
Upvotes: 2
Views: 293
Reputation: 28325
Take a look at this article/post.
Essentially, you hook up with the SetConsoleCtrlHandler and subscribe to the events.
Upvotes: 1
Reputation: 158349
There is the AppDomain.ProcessExit
event that you could hook up an event handler to. Note thought that it is "time boxed"; by default it is allowed to execute for a maximum of 3 seconds, so you should not do anything time consuming in there.
Upvotes: 1
Reputation: 564641
No, since there is no message pump for a close event.
However, the AppDomain is unloaded as the process is torn down, and this will fire AppDomain.DomainUnloaded. You can use that to trap an event as the program shuts down.
Upvotes: 1