I’m currently working on an application which uses PRISM 4 to divide its functionalities in different modules.
I noticed that my application’s Shell, which holds the modules’ views in its regions, is loaded and displayed before the modules are loaded.
This means that the Shell is displayed first, and a considerable amount of time later (about half a second), the modules are loaded and the views inserted into the Shell’s regions. It’s rather annoying, as the user is greeted with an empty shell at start-up, which isn’t very professional.
Is there any way to detect when all the modules have been loaded ? Any method I can override in the bootstrapper ?
If I could, I would like to hide the Shell (or display a loading adorner) until all the modules have been loaded.
I found a relatively simple solution.
My application has a class named ShellHandler, which is instanciated in the bootstrapper and registered in the Unity Container as a singleton:
I created in my ShellHandler a method which can be used by modules to flag themselves as loaded:
Finally, in my ModuleBase class, which all modules implement, I created an abstract method which is called during the initialization process:
Each module now resolves the instance of the ShellHandler singleton through their constructor:
And finally they implement the Abstract method from ModuleBase: