显示启动画面在一次 [英] Show a splash screen at once

查看:104
本文介绍了显示启动画面在一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在处理的慢启动的WinForm的应用程序(这是一个大的应用程序,并拥有许多控制组件)。控制组件是DevComponents。 NGEN应用于prevent JIT编译,而且加载时间只是略有下降。

We are dealing with slow start for WinForm applications (it is a large application and has many control assemblies). Control assemblies are DevComponents. Ngen was applied to prevent jit compilation, but the loading time just decreased a little.

该应用程序有一个启​​动画面,但它只应用程序启动后,将出现在12秒。有没有什么方法来显示启动画面一次?

The app has a splash screen, but it appears only in 12 seconds after the app has started. Is there any approach to show the splash screen at once?

我们目前的建议是创建一个启动画面一个轻量级的应用程序,运行在一个单独的进程中主要的应用程序,并关闭了轻量级的应用程序时,主要的应用程序的初始化过程。

Our current suggestion is to create a lightweight app with the splash screen, run the main app in a separate process, and close the lightweight app when initialization of the main app is done.

推荐答案

你永远不会得到一个闪屏的.NET应用程序显示的马上 即使你NGen'ed的组件,以消除JIT编译的时候,你还是要等待所有的.NET框架的DLL加载到内存中。这是一个pretty的大框架,这需要时间的不平凡的金额,在冷启动加载。没有什么可以真正做到这一点。

You're never going to get a splash screen for a .NET application to show instantly. Even if you've NGen'ed the assemblies to eliminate the JIT-compile time, you still have to wait while all of the .NET Framework DLLs are loaded into memory. It's a pretty large framework, and it takes a non-trivial amount of time to load upon a cold start. Nothing you can really do about that.

微软曾试图以缓解疼痛,尽可能。该<一href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.aspx"><$c$c>WindowsFormsApplicationBase类(它在 Microsoft.VisualBasic程序命名空间中定义,但不要让这种吓跑你,这是从C#应用程序非常有用的)提供了一个内置机制用于显示启动画面。所有你需要做的就是设置它的<一个href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.splashscreen.aspx"><$c$c>SplashScreen物业以适当的形式,和其他一切在幕后处理。它的最大响应时间被大量优化,即使在冷启动的情况,但它仍然不会是的即时的。

Microsoft has tried to ease the pain as much as possible. The WindowsFormsApplicationBase class (it's defined in the Microsoft.VisualBasic namespace, but don't let that scare you off; it's perfectly usable from a C# application) provides a built-in mechanism for showing a splash screen. All you have to do is set its SplashScreen property to the appropriate form, and everything else is handled behind the scenes. It's been heavily optimized for maximum response time, even in a cold-start situation, but it's still not going to be instant.

这是你唯一的另一种选择是写的小包装在非托管code,其唯一目的是扔闪屏了尽可能快地,然后调用.NET应用程序开始启动自身。较轻的,​​当然这里更好。 C ++是一种选择,但C可能是一个更好的选择。你需要最大限度地减少你必须链接外部库的数量,所以像MFC或Qt的一个框架是绝对的:您需要直接针对Windows的API

The only other option that you have is to write small wrapper in unmanaged code, whose only purpose is to throw the splash screen up as quickly as possible, then call your .NET application to start launching itself. The lighter the better here, of course. C++ is an option, but C is probably a better option. You need to minimize the number of external libraries that you have to link, so a framework like MFC or Qt is definitely out: you need to target the Windows API directly.

在Visual Studio团队做类似的​​事情在2010年VS他们的过程<一的pretty的有趣解释href="http://blogs.msdn.com/b/visualstudio/archive/2009/11/11/behind-the-scenes-splash-screen.aspx">available在他们的博客:

The Visual Studio team did something similar in VS 2010. They have a pretty interesting explanation of the process available on their blog:

尽管Visual Studio 2010中使用WPF其主窗口,使用WPF的闪屏,需要我们等待CLR和WPF初始化,然后我们就可以画画了屏幕上的一个像素。虽然我们已经在.NET 4.0中取得了CLR和WPF的启动速度了一些重大的改进,但仍不能完全满足原始的Win32的性能。因此,在选择是为了留在本地C ++ code和Win32的启动画面。

Even though Visual Studio 2010 uses WPF for its main window, using WPF for the splash screen would require that we wait for the CLR and WPF to initialize before we could paint a single pixel on the screen. While we’ve made some tremendous improvements in CLR and WPF startup speed in .Net 4.0, it still can’t quite match the performance of raw Win32. So, the choice was made to stay with native C++ code and Win32 for the splash screen.

但我不会花太多时间在这里。既然你通常应该给用户打开启动画面和关闭的选项,大多数用户会选择将其关闭,这是不可能的,很多人都不会看到它摆在首位。任何好的优化分析器会告诉你,这是不值得的优化。

But I wouldn't spend too much time here. Since you should generally give users the option to turn splash screens on and off, and most users will opt to turn it off, it's unlikely that very many people will ever see it in the first place. Any good optimization profiler would tell you that it isn't worth optimizing.

这篇关于显示启动画面在一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆