title: The calling thread cannot access this object because a different thread owns it
body: <p>I know this question has been asked a number of times on the site, however I've tried to follow the advice given but am getting nowhere.</p>
  
  <p>I have a method which is called from a separate thread which simply adds a TextBlock to a stackpanel on the GUI. However no matter how I try to implement this I keep getting the error: "The calling thread cannot access this object because a different thread owns it"</p>
  
  <p>Apologies if this is a very simple question, however I'm brand new to WPF....</p>
  
  <pre><code>private void AddTbToStackPanel(string text)
      {
          StackPanel stackPanel = stackPanel1 as StackPanel;
          TextBlock tb = new TextBlock();
          tb.Text = text;            
          stackPanel.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =&gt; { stackPanel.Children.Add(tb); }));
      }
  </code></pre>