title: How can I create WPF Window in BackgroundWorker?
body: <p>Can anybody explain me, how can I create WPF Window in BackgroundWorker thread without errors?</p>
  
  <p>I have some class (WPF Window):</p>
  
  <pre><code>public partial class Captcha : Window
      {
          public Captcha()
          {
              InitializeComponent();
          }
  
          private void SendCaptchaBtn_Click(object sender, RoutedEventArgs e)
          {
              DialogResult = true;
              this.Close();
          }
      }
  </code></pre>
  
  <p>In backgroundworker's DoWork-function I trying to create an object with this Window:</p>
  
  <pre><code>BackgroundWorker bgWorker = new BackgroundWorker();
  bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork);
  bgWorker.RunWorkerAsync();
  
  void bgWorker_DoWork(object sender, DoWorkEventArgs e)
          {
                  parser = new Parser();
                  parser.ParseFunc(tempKeywords);
          }
  </code></pre>
  
  <p>The Parser object has an "Captcha" Window:</p>
  
  <pre><code>Captcha captcha_dlg = new Captcha();
  </code></pre>
  
  <p>When I run program, I have runtime error at constuctor of Captcha-class point: <strong>The calling thread must be STA, because many UI components require this.</strong>
  What's wrong? Thansk for helping and sorry for my bad english :(.</p>