views:

109

answers:

3

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

+1  A: 

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.

Reed Copsey
+1  A: 

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.

Fredrik Mörk
+1  A: 

Take a look at this article/post.

Essentially, you hook up with the SetConsoleCtrlHandler and subscribe to the events.

Magnus Johansson