开发者

What happens when you close a .NET console application?

Is a meth开发者_JAVA技巧od 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


Take a look at this article/post.

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


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜