Znalazłem stosunkowo proste rozwiązanie.
Moja aplikacja posiada klasę o nazwie ShellHandler, który jest instanciated w inicjującego i zarejestrowany w kontenerze Unity jako pojedyncza:
Container.RegisterType<IShellHandler, ShellHandler>(new ContainerControlledLifetimeManager());
utworzonego w moim ShellHandler metodę, która może być użyta przez moduły do flaga same jak załadowany:
/// <summary>
/// Method used to increment the number of modules loaded.
/// Once the number of modules loaded equals the number of modules registered in the catalog,
/// the shell displays the Login shell.
/// This prevents the scenario where the Shell is displayed at start-up with empty regions,
/// and then the regions are populated as the modules are loaded.
/// </summary>
public void FlagModuleAsLoaded()
{
NumberOfLoadedModules++;
if (NumberOfLoadedModules != ModuleCatalog.Modules.Count())
return;
// Display the Login shell.
DisplayShell(typeof(LoginShell), true);
}
Wreszcie w mojej klasie ModuleBase, której wszystkie moduły wdrożenia, stworzyłem abstrakcyjną metodę, która jest wywoływana podczas inicjalizacji:
/// <summary>
/// Method automatically called and used to register the module's views, types,
/// as well as initialize the module itself.
/// </summary>
public void Initialize()
{
// Views and types must be registered first.
RegisterViewsAndTypes();
// Now initialize the module.
InitializeModule();
// Flag the module as loaded.
FlagModuleAsLoaded();
}
public abstract void FlagModuleAsLoaded();
Każdy moduł teraz rozwiązuje wystąpienie Singleton ShellHandler przez ich konstruktora:
public LoginModule(IUnityContainer container, IRegionManager regionManager, IShellHandler shellHandler)
: base(container, regionManager)
{
this.ShellHandler = shellHandler;
}
I wreszcie wdrożyć abstrakcyjnej metody z ModuleBase:
/// <summary>
/// Method used to alert the Shell Handler that a new module has been loaded.
/// Used by the Shell Handler to determine when all modules have been loaded
/// and the Login shell can be displayed.
/// </summary>
public override void FlagModuleAsLoaded()
{
ShellHandler.FlagModuleAsLoaded();
}
Nie sądzę, że źle robię to, czego potrzebujesz, ale czy spoglądasz na SplashScreen? – Paparazzi
Nie wiedziałem o SplashScreen, zaglądnę w to, dzięki. Nie jestem pewien, czy to rozwiąże problem, ponieważ nadal będę musiał określić, kiedy moduły zostały załadowane. –