标签:
先看一段代码:
1 Thread t = null; 2 3 t = new Thread(new ThreadStart( 4 delegate 5 { 6 try 7 { 8 //... 9 frm.ShowDialog();//报错 10 } 11 catch (ThreadAbortException ex) 12 { 13 Debug.WriteLine(ex.ToString()); 14 } 15 catch (Exception ex) 16 { 17 Debug.WriteLine(ex.ToString()); 18 } 19 20 } 21 ) 22 );
当上面的代码执行第 9 行 frm.ShowDialog() ,如果恰好调用 t.Abort() 此时会发生什么?
try { if (one.thread.IsAlive) { one.thread.Abort(); //one.thread.Join(); } } catch (ThreadAbortException ex) { Debug.WriteLine(ex.ToString()); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
... 接下来,我们如何处理这个问题呢?大家意见如何?
编程成 exe 运行,出现的问题如下:
标签:
原文地址:http://www.cnblogs.com/wagwei/p/5144051.html