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.