程序退出时,线程中catch (System.Threading.ThreadAbortException ex)
"unable to evaluate because the code is optimized or a native frame is on top of the call stack."
原因: 是因为线程中有对象因为线程的终止而报的错误. 本例中是因为线程函数中Waitone(),而外部关闭线程,导致异常.
解决方案:关闭线程前,先WaitSet()进行设置,然后再关闭.
"unable to evaluate because the code is optimized or a native frame is on top of the call stack."
原因: 是因为线程中有对象因为线程的终止而报的错误. 本例中是因为线程函数中Waitone(),而外部关闭线程,导致异常.
解决方案:关闭线程前,先WaitSet()进行设置,然后再关闭.
本文探讨了线程中出现System.Threading.ThreadAbortException的原因及其解决办法。异常通常发生在线程因外部关闭而提前终止的情况下,例如当线程等待时。文章提供了一个有效的解决方案:在关闭线程之前使用WaitSet()来避免此类异常。
181

被折叠的 条评论
为什么被折叠?



