简体   繁体   English

优化Windows窗体加载时间

[英]Optimize Windows Form Load Time

I have a Windows Form that takes quite a bit of time to load initially. 我有一个Windows窗体,最初加载需要相当多的时间。 However, each subsequent request to load the Form doesn't take as long. 但是,每个后续加载表单的请求都不会花费太长时间。 Is there a way to optimize a Form's load time? 有没有办法优化Form的加载时间?

You can use ngen . 你可以使用ngen

I also use this tip to reduce the Memory footprint on startup . 我也使用这个技巧来减少启动时内存占用

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Native Image Generator(Ngen.exe)是一种可以提高托管应用程序性能的工具。 Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. Ngen.exe创建本机映像,这些映像是包含已编译的特定于处理器的计算机代码的文件,并将它们安装到本地计算机上的本机映像缓存中。 The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly. 运行时可以使用来自缓存的本机映像,而不是使用实时(JIT)编译器来编译原始程序集。

You need to find out where the time is going before you can optimise it. 在优化之前,您需要找出时间。 Don't just ngen it without finding that out first, as if the problem is loading a 150MB background bitmap resource then you won't have done anything useful at all with ngen. 不要只是先找出它,就好像问题是加载一个150MB的背景位图资源那么你就不会对ngen做任何有用的事了。

You should disregard all specific advice or hunches about optimisation which arise without any measurements being made. 您应该忽略所有关于优化的具体建议或预感,而不进行任何测量。

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

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