【发布时间】:2009-04-05 08:06:58
【问题描述】:
我不知道为什么,但我不能再打断我自己的线程。
thread = new Thread(new ParameterizedThreadStart(this.doWork));
thread.Start(param);
...
thread.Interrupt();
//in doWork()
try {
...
}
catch (System.Threading.ThreadInterruptedException)
{
//it never hits here. it use to
}
我搜索并且我的代码中没有任何问题,这是唯一的问题 (System.Threading.ThreadInterruptedException)。那么发生了什么?使用调试器,我可以看到我的代码通过 thread.Interrupt(); 运行。如果我执行 thread.abort() 我将捕获 System.Threading.ThreadAbortException 异常。为什么它会捕获它而不是 ThreadInterruptedException?
【问题讨论】:
标签: c# multithreading exception