c#程序在程序退出前全关闭线程

下面是函数,但this.Closing += new System.EventHandler(this.Form1_FormClosing);这样写报错,load方法或者按钮的事件就可以。
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//在窗体即将关闭之前中止线程
thread.Abort();
}

this.FormClosing+= new System.EventHandler(this.Form1_FormClosing);
或者
this.FormClosing+=this.Form1_FormClosing;
都可以!!
是你事件绑定错了!!追问

this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
看到一种这样写的,通过了

温馨提示:答案为网友推荐,仅供参考
相似回答