静态终结 [英] Static Finalizer
问题描述
什么是正确的方法来执行一些静态finallization?
What is the right way to perform some static finallization?
没有静态的析构函数。该 AppDomain.DomainUnload
事件不会引发在默认域。该 AppDomain.ProcessExit
事件股所有事件处理程序之间三个秒(默认设置)的总时间,所以它不是真正可用。
There is no static destructor. The AppDomain.DomainUnload
event is not raised in the default domain. The AppDomain.ProcessExit
event shares the total time of the three seconds (default settings) between all event handlers, so it's not really usable.
推荐答案
基本上,你不能。设计围绕它自己的方式尽最大可能。
Basically, you can't. Design your way around it to the fullest extent possible.
不要忘了,一个程序可以的总是的突然终止反正 - 有人拔出电源是明显的例子。所以,你做任何事情必须是尽力而为 - 在这种情况下,我肯定的希望的是 AppDomain.ProcessExit
就足够好
Don't forget that a program can always terminate abruptly anyway - someone pulling out the power being the obvious example. So anything you do has to be "best effort" - in which case I'd certainly hope that AppDomain.ProcessExit
would be good enough.
你有什么需要做的,在特定的情况下?
What do you need to do, in your particular case?
这篇关于静态终结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!