In non-Prism WPF app, if I want to run code after initialization (e.g. execute the task specified by command-line argument), I can do it in Loaded event of the main window. However with Prism, the modules are initialized after main window is displayed, that is, IModule.Initialize() is called after Bootstrapper.CreateShell() and Bootstrapper.InitializeShell(). In this case which event/override should I use?
The last thing called by UnityBootstrapper.Run(bool runWithDefaultConfiguration) is InitializeModules() (well apart from a call to Logger.Log). So overide Run(...).
class Bootstrapper : UnityBootstrapper
{
...
public override void Run(bool runWithDefaultConfiguration)
{
base.Run(runWithDefaultConfiguration);
// modules (and everything else) have been initialized when you get here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With