Application.ThreadExit 事件

在某线程即将关闭时发生。当应用程序的主线程即将关闭时,首先引发该事件,随后是 ApplicationExit 事件。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Shared Event ThreadExit As EventHandler
用法
Dim handler As EventHandler

AddHandler Application.ThreadExit, handler
public static event EventHandler ThreadExit
public:
static event EventHandler^ ThreadExit {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public static void add_ThreadExit (EventHandler value)

/** @event */
public static void remove_ThreadExit (EventHandler value)
JScript 支持使用事件,但不支持进行新的声明。

备注

必须将事件处理程序附加到 ThreadExit 事件,才能在线程停止运行前执行未处理的、必需的所有任务。关闭该线程打开的文件,或释放垃圾回收器未回收的对象。

因为这是一个静态事件,所以您必须在 ApplicationExit 事件中分离附加到此事件的任何事件处理程序。如果不分离这些处理程序,它们仍将附加在该事件上并继续占用内存。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Application 类
Application 成员
System.Windows.Forms 命名空间
ExitThread