title: RadBusyIndicator not showing PRISM/MEF/WPF from ViewModel
body: <p>I am using MVVM/PRISM/MEF for my WPF application. It has one DataGrid with multiple records, and when one row is double clicked a separate view is added to region with multiple controls on it, the initialization of controls takes about 10 seconds for new screen, so thats why I want to show RadBusyIndicator during that time.</p>
  
  <p>Following in the XAML</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- This is Main View --&gt;
  &lt;!-- Module: MainModule, ViewModel: MainViewViewModel --&gt;
  &lt;telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding BusyContent}"&gt;
  &lt;!-- All PRISM regions are here --&gt;
  &lt;/telerik:RadBusyIndicator&gt;
  </code></pre>
  
  <p>Its view model is</p>
  
  <pre class="lang-cs prettyprint-override"><code>class MainViewViewModel : ViewModelBase
      {
          ImportingConstructor]
          public MainViewViewModel(IEventAggregator eventAggregator, IRegionManager regionManager, IServiceLocator serviceLocator)
              :base(eventAggregator, regionManager, serviceLocator)
          {
              eventAggregator.GetEvent&lt;BusyStateChangedEvent&gt;().Subscribe(OnBusyStateChanged,ThreadOption.BackgroundThread);
          }
  
          #region BusyStateChanged
  
          private void OnBusyStateChanged(bool newState)
          {
              IsBusy = newState;
          }
  
          #endregion
  }
  </code></pre>
  
  <p>And in other view when DataGrid row is double clicked ViewModelBase function is called, as follows</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ViewModelBase
  {
          private NavigationItem global_navItem = null;
  
          public virtual void OnNavigationItemChanged(NavigationItem item)
          {
              changeNav = true;
              global_navItem = item;
  
              //Firing event to change the state
              EventAggregator.GetEvent&lt;BusyStateChangedEvent&gt;().Publish(true);
  
              //Using BackgroundWorker, but its not showing any Busy Indicator as well
              var bw = new BackgroundWorker();
              bw.DoWork += bw_DoWork;
              bw.RunWorkerCompleted += bw_RunWorkerCompleted;
  
              bw.RunWorkerAsync();
          }
  
          void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
          {
              //Setting busy indicator to false
              EventAggregator.GetEvent&lt;BusyStateChangedEvent&gt;().Publish(false);
          }
  
          void bw_DoWork(object sender, DoWorkEventArgs e)
          {
              //DisplayView function is taking too long
              if (global_navItem != null) this.DisplayView(global_navItem);
          }
  }
  
  public void DisplayView(NavigationItem item)
          {
                      try
                      {
                          //This call is taking long as it initializes the View
                          MyCustomeUserControl view = this.ServiceLocator.GetInstance&lt;MyCustomeUserControl&gt;(item.viewName);
  
                          view.Region = this.Region;
                      }catch(Exception e)
                      {
                      }                   
          }
  </code></pre>
  
  <p>Events are being fired correctly and view is displayed correctly, but my problem is that Busy indicator is not shown at all, when I double click on DataGrid row the GUI become unresponsive, and after some time the new view appears. I am in doubt that this is problem of GUI thread being busy, but what can I do to avoid this, I have used <code>BackgroudWorker</code> already?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>1- I am raising PropertyChanged event for IsBusy Property. and I have already tried all options for Thread in event subscription. i.e. <code>Thread.BackgroundThread</code>, <code>Thread.UIThread</code> and <code>Thread.PublisherThread</code>. but no change.</p>
  
  <p>2- I have tested <code>Thread.Sleep</code> rather that <code>DisplayView</code> in <code>bw_DoWork</code>, and its showing <code>RadBusyIndicator</code> properly, so it means that GUI controls are being initialized in GUI thread, no matter I have created a <code>BackgroundWorker</code> for it.</p>