dynamic load module timing issue

Topics: Prism v2 - Silverlight 4
Jun 20, 2010 at 4:57 AM

Hi, I am new to Prism. A basic question: How do I make sure a module has been downloaded so that i can fire an event? Imagine that I have a toolbar module. The content, which is in a separate module, will be invoked when I click one of the toolbar button. However, it will cause problem if the content module is still in the process of downloading (asynchronously). What is the best practice on how to handle this? Thank you for any help provided.

Jun 22, 2010 at 5:20 PM
Edited Jun 22, 2010 at 5:22 PM


In order to make sure that a module has been initialized, you could check the State property inside the ModuleInfo instance corresponding to your module. You can access a collection of ModuleInfo in the Modules property of IModuleCatalog.

The code for that would look like this:

public ToolbarModule(IModuleCatalog catalog)


ModuleState MyModuleState= catalog.Modules.Where(m => m.ModuleName == "MyModule").FirstOrDefault().State;

if (MyModuleState==ModuleState.Initialized)...



Assuming that catalog is a reference to your IModuleCatalog implementation, which you can access through dependency injection (in this sample code i've used Constructor Injection with Unity).

However, please note that if you are publishing an event using Event Aggregation to communicate between modules, you shouldn’t have problems if you have no subscribers (that is, if no module is listening to that event).

On the other hand, if you want a module to be loaded strictly before another one, you could specify module dependencies, as explained on this article from the Prism documentation.

I hope you find this helpful.

Guido Leandro Maliandi

Jun 25, 2010 at 3:12 PM

thank you very much. I will give it a try