询问者
线程中的异常

问题
-
public void Begin()
{
Thread t=new Thread(TestMethod);
t.Start();
}
public void TestMethod()
{
throw new Exception("123");
}
调试的时候这个异常会不停的抛出来,感觉一直在执行代码一样,如果不是在自己建的线程中,则不会出现这个问题; 按我的理解,异常发生了,那么这个线程结束了,为什么不停的抛异常呢
- 已编辑 liuchengsong 2013年3月26日 8:56
全部回复
-
从你的代码看来:你的线程调用了一个产生异常的函数,自然要抛出异常的。
你是怎么调试的?可以说说嘛?或者你做一个控制台项目,模拟一下情况。(上传到SkyDrive)。
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats -
你Thread调用过几次?Begin是否被调用多次?
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats -
你至少应该提供一个主函数来让我们知道你是如何使用这些方法的。
同意Mike Feng
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.