AppDomain.ProcessExit 事件

定义

当默认应用程序域的父进程存在时发生。Occurs when the default application domain's parent process exits.

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

实现

注解

此事件的 EventHandler 可以在进程结束前执行终止活动,例如关闭文件、释放存储等。The EventHandler for this event can perform termination activities, such as closing files, releasing storage and so on, before the process ends.

从 .NET Framework 版本2.0 开始,将在注册事件处理程序的每个应用程序域中引发此事件。Beginning with the .NET Framework version 2.0, this event is raised in each application domain that registers an event handler.

备注

在 .NET Framework 中,所有 ProcessExit 事件处理程序的总执行时间都受到限制,就像所有终结器的总执行时间在进程关闭时受到限制。In .NET Framework, the total execution time of all ProcessExit event handlers is limited, just as the total execution time of all finalizers is limited at process shutdown. 默认值为两秒。The default is two seconds. 非托管主机可以通过将ICLRPolicyManager:: SetTimeout方法与OPR_ProcessExit枚举值一起调用来更改此执行时间。An unmanaged host can change this execution time by calling the ICLRPolicyManager::SetTimeout method with the OPR_ProcessExit enumeration value. 此时间限制在 .NET Core 中不存在。This time limit does not exist in .NET Core.

在 .NET Framework 版本1.0 和1.1 中,仅当在默认应用程序域中注册了事件处理程序时,才会引发此事件。In the .NET Framework versions 1.0 and 1.1, this event is raised only in the default application domain, and only if an event handler is registered in the default application domain.

若要为此事件注册事件处理程序,你必须具有所需的权限,或者引发 SecurityExceptionTo register an event handler for this event, you must have the required permissions, or a SecurityException is thrown.

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

适用于