gpt4 book ai didi

asp.net - 太多的 Try Catch block 会导致性能下降?任何替代解决方案?

转载 作者:行者123 更新时间:2023-12-05 01:11:34 25 4
gpt4 key购买 nike

我正在使用带有 .net framework 4 的 c# 开发一个网站。OO 概念已经实现。每一层都有一些 Try Catch block ,用于处理不同的错误并返回不同的错误消息。我发现加载时它变得越来越慢,因为 try catch block 越来越多。我想知道这是为什么。任何替代解决方案?如果我错了,请纠正我。感谢您的回复。

最佳答案

使用 try/catch block 没有错。它们不会改变性能。什么改变性能是抛出错误!

具体见以下网址:

Throwing exceptions can be very expensive, so make sure that you don't throw a lot of them. Use Perfmon to see how many exceptions your application is throwing. It may surprise you to find that certain areas of your application throw more exceptions than you expected. For better granularity, you can also check the exception number programmatically by using Performance Counters.

http://msdn.microsoft.com/en-us/library/ms973839.aspx

关于asp.net - 太多的 Try Catch block 会导致性能下降?任何替代解决方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com