Visual Studio 2015如何禁用异常输出 [英] Visual Studio 2015 How to disable exceptions outputs

查看:131
本文介绍了Visual Studio 2015如何禁用异常输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在制作带有更新和绘图的C#应用​​程序,但我发现更新确实很慢,尽管没有任何繁琐的表达方式.

I was making a C# application with an update and a draw, and I figured out the update was really slow, although there wasn't any kind of heavy expression.

在独立于Visual Studio启动我的应用程序之后,我发现它的速度快了100倍.问题在于,对于每次try {} catch {},VStudio都会在输出控制台中输出一条错误消息.每次更新都会显示100条错误消息,这使我的应用程序变慢了.

And after having launched my application independently from Visual Studio, I figured out that it was like 100x faster. The problem was that for every try{} catch {}, VStudio output an error message in the output console. Which made like 100 errors message/ update, which was what slowed down my application.

现在,我用if(){}替换了try {},它可以正常工作.现在,我想知道是否存在一种方法,使得VStudio不会在控制台中输出错误,以便我可以在不冻结应用程序的情况下做出try {}语句.

Now I replaced the try{} by an if(){}, and it works perfectly. Now I'd like to know wether there's a way that VStudio does not output errors in the console, so that I can make try{} statements without freezing my application.

有什么主意吗?

推荐答案

尝试类似

try {
    // code here
}
except YourException {}

如果您不想执行任何操作,请

except 块保留为空.如果您想在异常发生时做点什么,请将其放在其中.

Leave except block empty if you don't want to take any action. If you want to do something when exception comes, put that inside there.

这篇关于Visual Studio 2015如何禁用异常输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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