title: WPF: The Output is Correct But the Window doesn't show up
body: <p>I am developing a WPF application. I need a method to run every 5 seconds and output the information it captures. I used the difference of DateTime to decide if 5 second has passed. When I started running it, I could see the correct information is outputted every 5 seconds. However, the app's window didn't show up, neither could I find it's icon in status bar. Here is my code public MainWindow():</p>
  
  <pre><code>InitializeComponent();            
      DateTime now;
          DateTime _lastTime5SecondsHadPassed = DateTime.Now; ;
          TimeSpan elapsed;
          do
          {
              now = DateTime.Now;
              elapsed = now - _lastTime5SecondsHadPassed;
              if (elapsed.Seconds &gt;= 10)
              {
                  title = GetActiveWindowTitle();
                  Trace.WriteLine(title);
                  _lastTime5SecondsHadPassed = DateTime.Now;
              }
  
          } while (true);
  </code></pre>
  
  <p>Later I found whichever window I moved the this code into, other windows would appear normally but everytime when it switch to the window with this code, the window would not show up. Does anyone have any idea? Thanks in advance!</p>