title: Thread cannot access the object
body: <p>I declared a field:</p>
  
  <pre><code>WriteableBitmap colorBitmap;
  </code></pre>
  
  <p>Then I created a simple thread which does something:</p>
  
  <pre><code>private void doSomething()
  {
      // ... bla bla bla
      colorBitmap = new WriteableBitmap(/* parameters */);
      myImage.Source = colorBitmap; // error here:S
  }
  </code></pre>
  
  <p>In Windows_Loaded event I declared and started a new thread:</p>
  
  <pre><code>private void window_Loaded(object sender, RoutedEventArgs e)
  {
      Thread th = new Thread(new ThreadStart(doSomething));
      th.Start();
  }
  </code></pre>
  
  <p>The problem is that I couldn't change myImage's source. I've got an error like:</p>
  
  <blockquote>
    <p>InvalidOperationException was unhandled
    The calling thread cannot access this object because a different thread owns it.</p>
  </blockquote>
  
  <p>I tried to use Dispatcher.Invoke, but it didn't help...</p>
  
  <pre><code>Application.Current.Dispatcher.Invoke((Action)delegate
  {
      myImage.Source = colorBitmap;
  });
  </code></pre>
  
  <p>I was searching for some answers, but never found the case exactly as mine. Could any1 help me to understand how to solve problems like this (I've had the same problem recently, but I couldn't call the method, because other thread owned it).</p>