title: How to open a new window from a timer event in WPF
body: <p>I'm trying to show a new window if certain conditions are met, which is checked periodically using a <code>System.Timers.Timer</code>.  </p>
  
  <p>I am very new to WPF but from what I've read from my <a href="https://stackoverflow.com/questions/28866161/how-to-avoid-wpf-application-not-responding-when-logging-off">previous question</a>, dispatchtimers use the UI thread and are suitable for UI components, whereas the System.Timers.Timer event runs on a threadpool thread.  I had previously accomplished this using my dispatchtimer, but this caused my program to stop responding when trying to exit.</p>
  
  <p>Realizing that the error message: <code>"The calling thread must be STA, because many UI components require this."</code> is probably referring to the fact that I can't open a new window using my System.Timers.Timer, I tried doing the following:</p>
  
  <pre><code>private void timer1_Tick(object sender, EventArgs e)
  {
      //... other timer functions
      if(conditions are met)
      {
            ShowNewWindow();
      }
  
  }
  private static void ShowNewWindow()
  {
      NewWindow nw = new NewWindow();
      nw.Show();
  }
  </code></pre>
  
  <p>This results in the same error message.  Do I need to use a different timer type?</p>