title: WPF UI on multiple threads?
body: <p>I have a large WPF MVVM application (over 100 windows currently and growing.) Although I try to do everything I can on background threads there always comes a time the results must be sent back to the UI thread to be displayed. When you have many windows doing this at the same time it can effect performance.</p>
  
  <p>I've tried to run each window on a separate UI thread in the past but ran into so many threading issues I had to revert back to WPF's default model of only 1 UI thread per app. </p>
  
  <p>I know with windows 10 coming many users will open even more windows on separate desktops and thus make this worse.</p>
  
  <p>Anyone know how to get multiple UI threads to work correctly in WPF? Or have any info I can investigate to help get my app further down this road?</p>
  
  <p>I approach I tried in the past was to do something similar to this:</p>
  
  <pre><code>private void OnCreateNewWindow(
     object sender,
     RoutedEventArgs e)
    {
     Thread thread = new Thread(() =&gt;
      {
       Window1 w = new Window1();
       w.Show();
  
       w.Closed += (sender2, e2) =&gt;
        w.Dispatcher.InvokeShutdown();
  
       System.Windows.Threading.Dispatcher.Run();
      });
  
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
    }
  </code></pre>
  
  <p>This was about 2 years ago and I can no longer recall all the issues I faced using this unfortunately.</p>
  
  <p>Is there another way? Has anyone gotten an app with many windows to work correctly using this approach or another?</p>