简体   繁体   English

WPF应用程序启动时间太长

[英]WPF Application takes too long to start

I am creating a WPF Application that uses Fluent library. 我正在创建一个使用Fluent库的WPF应用程序。

On my computer with Windows 7, 2GB RAM and AMD Triple Core processor, after double clicking on the program icon, The Splash image shows after about 1-2 seconds. 在装有Windows 7、2GB RAM和AMD Triple Core处理器的计算机上,双击程序图标,大约1-2秒后会显示启动画面。

But on my brother's old computer with Windows XP, 512MB RAM and Intel Celeron 2.0 GHz Processor (Single core), after double clicking on the program icon, First, a process called PresentationFontCache.exe runs and it uses almost 100% of CPU for some seconds. 但是,在我兄弟的装有Windows XP,512MB RAM和Intel Celeron 2.0 GHz处理器(单核)的旧计算机上,双击程序图标后,首先,运行一个名为PresentationFontCache.exe的进程,它使用了几乎100%的CPU秒。 And Total time is needed for displaying the initial Splash image is almost 30 seconds (or more). 而且显示初始启动画面所需的总时间将近30秒(或更长时间)。

I don't want that some users have to wait 30 seconds for displaying splash image and about 7-8 seconds for loading application. 我不希望某些用户需要等待30秒才能显示初始图像,而不必等待大约7-8秒来加载应用程序。 (my application load process takes 7-8 seconds) (我的应用程序加载过程需要7-8秒)

Also I think 1-2 seconds is too high for just display initial SplashImage , It should display immediately. 我也认为1-2秒对于仅显示初始SplashImage来说太高了,应该立即显示。

How to solve this problem? 如何解决这个问题呢?

But on my brother's old computer with Windows XP, 512MB RAM and Intel Celeron 2.0 GHz Processor 但是在我兄弟的旧计算机上,该计算机具有Windows XP,512MB RAM和Intel Celeron 2.0 GHz处理器

Yeah, and guess waht - starting internet exlporer also takes a long time. 是的,猜猜是什么-启动互联网扩展程序也需要很长时间。 This is not a computer, it is crap. 这不是计算机,是胡扯。 At least 1gb memoery would help. 至少1GB的备忘录会有所帮助。 WPF apps are not super low resorue aapps, they are made for modern OS. WPF应用程序不是超低资源的aapps,它们是为现代OS开发的。

I don't want that some users have to wait 30 seconds for displaying splash image 我不希望某些用户需要等待30秒才能显示初始图像

Use the .NET standard flash mechanism (that loads even before the runtime is fully initialzied). 使用.NET标准闪存机制(甚至在完全初始化运行时之前就已加载)。

http://www.abhisheksur.com/2010/05/creating-splash-screen-without-code.html http://www.abhisheksur.com/2010/05/creating-splash-screen-without-code.html

THEN load the WPF code. 然后加载WPF代码。

Sound like you could profile your application for performance to see where your bottleneck is and discover what is causing it so that you can know what to fix in your code to optimize performance. 听起来您可以分析应用程序的性能,以查看瓶颈所在并发现导致瓶颈的原因,以便您知道要在代码中修复的内容以优化性能。

You can use the classes System.Diagnostics namespace. 您可以使用类System.Diagnostics命名空间。 Like PerformanceCounter class etc. 像PerformanceCounter类等。

If you have some money to spend you could use RedGate Develper Bundle for .NET It has Performance profiler, Memory profiler etc. 如果您有足够的钱可以使用RedGate Develper Bundle for .NET,它具有性能分析器,内存分析器等。

There also other cheaper alternatives. 还有其他更便宜的选择。

Presentationfontcache.exe is a is a Windows Presentation Foundation Service from Microsoft Corporation belonging to .NET Framework. Presentationfontcache.exe是Microsoft Corporation属于.NET Framework的Windows Presentation Foundation服务。 It normally uses high CPU. 通常使用高CPU。

You could try stopping the service, by deleting the file it creates: Windows\\ServiceProfiles\\LocalService\\AppData\\Local\\FontCache4.0.0.0.dat and restarting the service to check if that helps. 您可以尝试通过删除服务创建的文件来停止服务:Windows \\ ServiceProfiles \\ LocalService \\ AppData \\ Local \\ FontCache4.0.0.0.dat,然后重新启动服务以检查是否有帮助。

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

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