thread.Abort()之后会发生什么?
假设我有以下代码:
Thread mWorker = new Thread(new ThreadStart(this.run));
..
mWorker.Start();
**where**
private void run()
{
Logger.d(TAG, "run()");
...
try {
while (this.mRunning){
...
}
} catch (ThreadAbortException tae){
Logger.e(TAG,"some msg", tae);
this.doSomething();
} catch (IOException ioe){
Logger.e(TAG,"some msg", ioe);
this.doSomething();
} catch (Exception e){
Logger.e(TAG,"some msg", e);
this.doSomething();
} finally {
gracefoulyClose();
}
Logger.d(TAG, "run() - ended");
}
线程更为复杂,但本质在此展示。那么当Abort()被调用时会发生什么?我的catch会起作用并继续调用doSomething()吗?
因为我仍然能在控制台中看到:
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
但是我为此有一个条件。对吧?