dynamic splashscreen with mef and prism v4

Topics: Prism v4 - WPF 4
May 23, 2011 at 3:18 PM
Edited May 23, 2011 at 3:18 PM

I would like to implement a dynamic splashscreen for a prism application. There are some ressources that address this kind of requirement, but I'm not using MEF as the bootstrapper.

There is also an interesting screencast on channel 9 about Improving perceived WPF app startup performance with MEF and a Splash Screen which I believe could be a good starting point.

How would you handle such a requirement ?

Thanks

May 23, 2011 at 8:16 PM

Hi,

One possible way to fulfill your goal could be to load your necessary modules on demand and perform the necessary operations in your service in the background while you display the splash screen in your application. You can read more about modularity in Chapter 4: Modular Application Development.

On the other hand, you could defer the initialization of the Shell by overriding the Run method in your Bootstrapper to alter the application's initialization sequence so as to avoid calling the CreateShell and InitializeShell, and make your bootstrapper subscribe to the OnCompleted event in a service of yours that needs to perform an operation, so that when all the operations are complete these methods are called to close the splash screen and load the shell in the application window.

You might find the following thread handy where deferring the shell is covered.

Take into account Prism is Dependency Injection Container agnostic. This means you could achieve the same functionality as an application developed using MEF.

I hope you find this information useful.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

 

May 23, 2011 at 9:51 PM

Hi Miguel,

I being looking for an splash screen sample using prism v4.  Can you create a small repo sample describing your steps above using UnityBootstrapper?  I am new to prism and I need this type of functionality for a demo that I am working on.  Thanks in advance.  

Regards,

John Montoya

Developer
May 23, 2011 at 10:34 PM

Hi John,

We've created a sample, which you can find here.

In the sample, we've overriden the Bootstrapper.Run method, so as to perform a lenghty operation in a service, and show a splash screen whilst that operation is performing; when the operation is completed, the splash screen is closed and the shell is shown.

Note that, while regularily the shell is loaded before all your modules, this would imply that your modules can be loaded after the shell. In case you don't wish for that to happen, you could set your modules to be loaded on demand, and call the ModuleManager.LoadModule method for each of your modules in the handler of the LenghtyOperationCompleted event.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 24, 2011 at 8:47 AM

Thanks, that's very helpful. 

Fabien

May 24, 2011 at 2:24 PM

Thanks Guido,

Nice example.

John