我初始化一个线程的静态线程如下图所示STA线程中止异常
Thread GenerateKeywords;
private void btnStart_Click(object sender, EventArgs e)
{
//Initializes the Test Thread
Test = new Thread(TestMethod);
//Sets the apartment state to Static
Test.SetApartmentState(ApartmentState.STA);
//Starts the GenerateKeywords Thread
Test.Start();
}
,但是当我通过这种方法
private void btnStop_Click(object sender, EventArgs e)
{
if (Test != null)
Test .Abort();
}
这是给下面的异常中止这个线程: “ mscorlib.dll中发生类型'System.Threading.ThreadAbortException'的第一次机会异常 线程0x13dc已退出,并且代码为0(0x0) “
如何摆脱这个异常?
它不*是一个例外,只是来自调试器的通知发现了异常。这是正常的,Thread.Abort()注入一个异常。 *不*修复这个问题。 – 2010-09-21 11:22:27