简体   繁体   English

.NET:Windows表单/控件性能

[英].NET: Windows forms/controls performance

We have an application with very heavy UI. 我们的应用程序具有非常重的UI。 Recently our clients started complaining to application startup performance. 最近我们的客户开始抱怨应用程序启动性能。 (Previously our controls/forms were initialized while a some kind of the splash screen with a message 'starting' was shown). (之前我们的控件/表单已初始化,而某些启动画面显示消息“开始”)。

I've made a research and found that the control's InitializeComponent() (which is generated by VS designer) method call can take up to ~0.4-0.5s for complex controls. 我做了一个研究,发现控件的InitializeComponent()(由VS设计器生成)方法调用对于复杂的控件可能需要~0.4-0.5s。 And there are a lot of such controls, so I'm getting ~10-15 seconds of application startup time as the result. 并且有很多这样的控件,因此我得到大约10-15秒的应用程序启动时间。 There are nothing that could be really heavy there, only controls initialization (for example, different toolstrips, toolstripbuttons, menustrips initialization, setup of different texts etc). 那里没有什么可以真的很重,只控制初始化(例如,不同的工具条,工具条,初始化,不同文本的设置等)。

Is there a way to improve performance of controls initialization in this case? 在这种情况下,有没有办法提高控件初始化的性能? Maybe some kind of caching or smth like that (so our application will start up slowly only during the first load)? 也许某种缓存或类似的那样(所以我们的应用程序只会在第一次加载时缓慢启动)?

PS We're using .NET 2.0 PS我们正在使用.NET 2.0

Thanks in advance. 提前致谢。

You indicate that you've performed at least some rudimentary analysis of your app's start-up time, but have you thoroughly profiled your app using Visual Studio's profiler, ANTS or similar? 您表明您已经对应用程序的启动时间进行了至少一些初步分析,但是您是否使用Visual Studio的分析器,ANTS或类似工具对您的应用程序进行了全面的分析?

Thoroughly profiling of your app will give you the most accurate break-down of where your app spends its time. 彻底分析您的应用程序将为您提供最准确的分解应用程序花费时间的地方。 Anything less and you're just guessing. 什么都没有,你只是在猜测。

You might also consider NGEN'ing portions of your app and re-profiling your app's start-up times to determine whether the NGENning of your code actually delivered a performance boost. 您可能还会考虑NGEN的应用程序部分并重新分析应用程序的启动时间,以确定代码的NGENning是否实际上提升了性能。

However, if you've built something that's very complex, you may simply be asking too much of your users' machines. 但是,如果你构建了一些非常复杂的东西,你可能只是过多地询问用户的机器。 This is why it's VITAL to measure performance of your code on tin that's as similar as possible to your end-users' hardware and environment. 这就是为什么测量代码在锡上的性能与最终用户的硬件和环境尽可能相似的原因。

Another thing to consider is that WinForms doesn't really take advantage of modern-day hardware accelerated graphics. 另一件需要考虑的事情是,WinForms并没有真正利用现代硬件加速图形。 You may find that porting to WPF gives you just the boost you need, but be sure to prototype and profile carefully before committing significant resources to this path. 您可能会发现移植到WPF会为您提供所需的增强功能,但在将大量资源提交到此路径之前,请务必仔细进行原型设计和配置文件。

HTH. HTH。

  • Load data asynchronous 加载数据异步

  • Buy faster pc's 买更快的电脑

  • Use WPF (.net 3.5) 使用WPF(.net 3.5)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM