Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Gathering User Information before Bootstrapper Runs

$
0
0
Hi,

Based on my understanding, what you need is to wait for the asynchronous operation to complete before initializing the modules. Hence, you need to invoke the InitializeModules method after the "completed event" is raised. As far as I know, the Bootstrapper is not prepared to wait for asynchronous calls to finish, but you can override its Run method to change the bootstrapping logic to fit your needs.

For example, as a possible approach, you could override the Run method of your bootstrapper and copy the original code, with the difference that instead of calling the InitializeModules method directly, you could first check if the operation was completed (for example with the UserId property) and if not, you could subscribe to the UserInitialized event and invoke the InitializeModules method inside the event handler (remember to unsubscribe from this event.) You can find the Run method's base code in the UnityBoostrapper (in case you are using Unity) or in the MefBootstrapper (in case you are using MEF) in the Prism library's source code.

Like this, the you can ensure that when the modules are initialized the information required from the web service is available. Also, this would not block the rest of the of the initialization process as the initialization of the modules is the last step in the bootstrapping sequence. You find more about this sequence here:
I hope this helps,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Viewing all articles
Browse latest Browse all 1878