从任务打破异常停止视觉工作室 [英] Stop visual studio from breaking on exception in Tasks

查看:128
本文介绍了从任务打破异常停止视觉工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下code:

Task load = Task.Factory.StartNew(() => {//Some Stuff Which Throws an Exception});

try
{
    load.Wait();
}
catch (AggregateException ex)
{
    MessageBox.Show("Error!");
}

当过一个例外任务被抛出,我希望它泡了被夹在尝试捕捉,而不是视觉工作室打破在异常引起的地步。

When ever an exception is thrown in the Task, I want it to bubble up get caught in the try catch instead of visual studio breaking at the point the exception is caused.

我试过谷歌和一些建议我添加此 [DebuggerHidden] 我的方法的顶部,但它不能正常工作

I Tried google and some suggested I add this [DebuggerHidden] on top of my method but it doesn't work

推荐答案

好吧,我发现了如何做到这一点。答案是正确的这里的说明栏目

Ok I found out how to do it. The answer is right here in the note section

在仅我的code已启用时,Visual Studio在某些情况下会打破抛出异常的行,并显示一个错误,指出消息异常不被用户code处理。此错误是良性的。您可以preSS F5继续,看到是体现在这些例子中,异常处理的行为。 要打破的第一个错误prevent Visual Studio中,只需取消选中启用仅我的code。在工具复选框,选项,调试,将军。

When "Just My Code" is enabled, Visual Studio in some cases will break on the line that throws the exception and display an error message that says "exception not handled by user code." This error is benign. You can press F5 to continue and see the exception-handling behavior that is demonstrated in these examples. To prevent Visual Studio from breaking on the first error, just uncheck the Enable Just My Code checkbox under Tools, Options, Debugging, General.

这篇关于从任务打破异常停止视觉工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆