Aug 13, 2013 at 10:13 AM
Edited Aug 13, 2013 at 10:18 AM
I am using Prism 4.1 with MEF. What i want is to run Bootstrapper on background silently while my login window shows up. So that user can continue to input username and password while the Bootstrapper is loading a lot of modules.
In order to get this, I am using BackgroundWorker.However i get error saying "The calling thread must be STA, because many UI components require this.". I tried to use a thread with STA mode to run the BackgroundWorker, however it caused other issues
that i could't figure out. in order to avoid this issue, i return null as a result of CreateShell()
when the Bootstrapper is running. and after Bootstrapper is loaded completely, i set the Shell property via SetShell() as shown in below. However, I got error saying "The region manager does not contain the ShellApplicationMdiContainerRegion region."
. The "ShellApplicationMdiContainerRegion" is the region name I defined in ShellView xaml. Seems to me that this region is not registered in the prism.
Could someone shred some light on this?
By the way, I neither want to use a thread with STA mode nor Application.Current.Dispatcher.Invoke method to run Bootstrapper as any of them will cause other big issues.
in my Bootstrapper class:
protected override DependencyObject CreateShell()
in my login class:
private void Backgroundworkder_DoWork(object sender, DoWorkEventArgs e)
bootstrapper = new Bootstrapper();
private void Backgroundworkder_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
public void SetShell()
this.Shell = this.Container.GetExportedValue<ShellView>();