AppDomain.DomainUnload 事件


在即将卸载 AppDomain 时发生。Occurs when an AppDomain is about to be unloaded.

 event EventHandler ^ DomainUnload;
 virtual event EventHandler ^ DomainUnload;
public event EventHandler DomainUnload;
member this.DomainUnload : EventHandler 
Public Custom Event DomainUnload As EventHandler 



此事件的 EventHandler 委托可以在卸载应用程序域之前执行任何终止活动。The EventHandler delegate for this event can perform any termination activities before the application domain is unloaded.

需要在卸载时执行处理的每个应用程序域都应为此事件注册事件处理程序。Each application domain that needs to perform processing when it is unloaded should register an event handler for this event. 不应使用共享事件处理程序,因为 EventHandler 委托不标识正在卸载的域。A shared event handler should not be used, because the EventHandler delegate does not identify the domain that is being unloaded.


此事件永远不会在默认应用程序域中引发。This event is never raised in the default application domain.

不要对引发事件的线程做出假设。Do not make assumptions about the thread the event is raised on. 事件可以在不同于调用 Unload 方法的线程上引发。The event can be raised on a different thread than the one that called the Unload method.

有关处理事件的详细信息,请参阅处理和引发事件For more information about handling events, see Handling and Raising Events.