title: Create element in background thread an then add to main-interface
body: <p>i have a problem with threading in WPF. I want to have created a complex user interface and then i want to add it to my main-window. While this complex user interface is creating i want to show a progress bar in my main window. I think this only could be made with threads. But there is a problem. The created element can't be added to main window because it is created in a separate thread.
  Do anybody know if there is a possibility to transfer UIElements that are created in a background-thread to the main-thread. 
  If i try in a simple way it says that the object can't be accessed because it is in a separate thread. I have already made my progress-bar thread safe.</p>
  
  <p>I hope following example explain a bit better what i want to to.</p>
  
  <pre><code>StackPanel tcForm = new StackPanel();
  Semaphore loadedSema = new Semaphore(0,1);
  Thread thread = new Thread(new ThreadStart(delegate(){
             //Formular should be created in background               
             tcForm.Children.Add(new Formular());
             ProgressBar.AddProgress();
             //...other things
             loadedSema.Release();
  }));
  thread.start();
  loadedSema.WaitOne();
  </code></pre>
  
  <p><code>new Formular()</code> runs a very long time, so i thought about creating in background.</p>
  
  <p>It is also impossible to add <code>Formular</code> to a variable and then add it main thread.</p>
  
  <pre><code>//this is also impossible
  
  //in background-thread
  form = new Formular
  
  //in main-thread
  tcForm.Children.Add(form);
  </code></pre>
  
  <p>I hope that there is a way to this.
  Would be nice if there are some advices, </p>
  
  <p>Thanks, Martin</p>