title: WPF Cross Thread Object Access
body: <p>I have an issue regarding cross thread calls in WPF.</p>
  
  <pre><code>            foreach (RadioButton r in StatusButtonList)
          {
              StatusType status = null;
              r.Dispatcher.Invoke(new ThreadStart(() =&gt; status= ((StatusButtonProperties)r.Tag).StatusInformation));
              if (AppLogic.CurrentStatus == null || AppLogic.CurrentStatus.IsStatusNextLogical(status.Code))
              {
                  SolidColorBrush green = new SolidColorBrush(Color.FromRgb(102, 255, 102));
                  r.Dispatcher.Invoke(new ThreadStart(() =&gt;  r.Background = green));
              }
              else
              {
                  SolidColorBrush red = new SolidColorBrush(Color.FromRgb(255, 0, 0));
                  r.Dispatcher.Invoke(new ThreadStart(() =&gt; r.Background = red));
              }
          }
  </code></pre>
  
  <p>When I run this code, it works correctly for the first iteration. However during the second iteration the line:</p>
  
  <pre><code>  r.Dispatcher.Invoke(new ThreadStart(() =&gt; status= ((StatusButtonProperties)r.Tag).StatusInformation))
  </code></pre>
  
  <p>Causes this exception:</p>
  
  <pre><code>Cannot use a DependencyObject that belongs to a different thread than its parent Freezable.
  </code></pre>
  
  <p>I've tried a few solutions but I can't find anything workable.</p>
  
  <p>Any help appreciated!</p>