navigation
 Wednesday, August 27, 2008

In WPF, one well known problem is that it takes a long time, maybe 30 seconds or a minute, for the main screen of the application to show after a reboot. This is because a host of WPF and DirectX DLLs need to be loaded and initialized before the WPF window can show. Creating a WPF splash screen window doesn't help, because that is a WPF window too and also takes ages to load...

To work around this, we followed some good examples on line and wrote our own little hack that use Native Win32 API calls to display a bitmap in a window, then load the main window, and when the main window is loaded, hide the bitmap window. It worked pretty well.

Well, today, while googling something else, I chanced upon this link describing the SplashScreen class, and this page showing how to add a Splash Screen to a WPF application. Noteworthy is this excerpt:

Note:

It is not necessary to write any code to display a splash screen. Starting in Visual Studio 2008 SP1, you can quickly configure a splash screen with default settings.

Now isn't that nice? Apparently, the WPF team added this functionality to the product! What is more, it says "The splash screen is displayed by using native code, before the WPF application instance is created. The splash screen is displayed in the center of the screen. When the application is loaded, the splash screen fades."

It seems the implementation is the same as our hack...

So much for being on the leading edge.

Anyway, enthralled by this, I went into Visual Studio 2008 and tried to use the new feature. But it wasn't there! Now, I have Visual Studio 2008 SP1 Beta, so this must have made it into the RTM after the beta! So I went to install the SP1 RTM version from here, along with the RTM .NET Framework 3.5 SP1. It turns out that as part of the install, the SP checks if you have the SP beta installed, and if so asks you to remove it first. To that end there is a utility that uninstalls the beta and any other non compatible hot fixes, found here.

I am still in the process of downloading all these bits and pieces, but I am very excited about all of this! I hope this blog will help you not reinvent the wheel the way I did, and also help you uninvent it if you have!