title: Error: The calling thread cannot access this object because a different thread owns it
body: <p>I get this error. Here is the code:</p>
  
  <pre><code>    Image image;
      BitmapImage BmpImg;
      MemoryStream ms;
  
      public void Convert()
      {
          ms = new MemoryStream();
          image.Save(ms, ImageFormat.Jpeg);
  
          BmpImg = new BitmapImage();
          BmpImg.BeginInit();
          BmpImg.StreamSource = new MemoryStream(ms.ToArray());
          BmpImg.EndInit();
      }
  
      private void Btn_Click(object sender, RoutedEventArgs e)
      {     
          Dispatcher.Invoke(new Action(() =&gt; { Image.Source = BmpImg; }));
      }
  </code></pre>
  
  <p>How to convert a System.Drawing.Image to BitmapImage and display the same on wpf?</p>