卸载事件的默认应用程序域? [英] Unload event for the default AppDomain?
问题描述
我需要有一个事件发射时的任意的应用程序域卸载 - 包括默认的过程之一。与AppDomain.DomainUnload的问题是,它仅触发用于非默认程序域。此外,AppDomain.ProcessExit具有有限的执行时间,这是我不能依靠。
I need to have an event fired whenever any AppDomain unloads - including the default one of the process. The problem with AppDomain.DomainUnload is that it only fires for non-default AppDomains. Furthermore, AppDomain.ProcessExit has limited execution time, which I cannot rely on.
任何建议,我如何能实现,这将是极大的AP preciated!
Any suggestions as to how I can achieve this would be greatly appreciated!
(或者,其发射时,后台线程(Thread.IsBackground ==真)工作过的事件。)
(Alternatively, having an event fired when a background thread (Thread.IsBackground == True) works too.)
推荐答案
你为什么不把你的code在主要的结束?
Why do you not put your code in the end of Main?
对于一个事件:
没有没有事件将被执行的应用程序域卸载时。如果你是一个库开发人员,你添加一个析构函数的入门级。但要小心,一切都可能无法正常回收。阅读这样的回答: http://stackoverflow.com/a/2735431/70386
No there is no event which will get executed when the application domain is unloaded. If you are a library developer you add a destructor to your entry class. But beware that everything might not be collected properly. Read this answer: http://stackoverflow.com/a/2735431/70386
这篇关于卸载事件的默认应用程序域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!