title: EmguCV ImageGrabbed Event WPF App
body: <p>I have problems with the following code</p>
  
  <pre><code>namespace MyApp
  {    
      public partial class PhotoWindow : Window
      {
          private Capture _capture;
  
          public PhotoWindow ()
          {
              InitializeComponent();    
              _capture = new Capture();
  
              if (_capture != null)
              {
                  //&lt;Image&gt; in XAML
                  CaptureSource.Width = 150;
                  CaptureSource.Height = 180;
  
                  _capture.ImageGrabbed += ProcessFrame;
                  _capture.Start();                
              }
  
              Activated += (s, e) =&gt; _capture.Start();
              Closing += (s, e) =&gt;
              {
                  if (_capture == null) return;
                  _capture.Stop();                
                  _capture.Dispose();
              };
          }
  
          private void ProcessFrame(object sender, EventArgs e)
          {
              try
              {
                  Image&lt;Bgr, Byte&gt; frame = _capture.RetrieveBgrFrame();                   
                  CaptureSource.Source = Helper.ToBitmapSource(frame);
              }
              catch (Exception exception)
              {
  
                  System.Windows.MessageBox.Show(exception.ToString());
              }
          }
  
      }
  }
  </code></pre>
  
  <p>when I run the application I get the exception <code>System.InvalidOperationException: The thread that this call can not access this object because the owner is another thread</code> on line <code>CaptureSource.Source = Helper.ToBitmapSource(frame);</code></p>
  
  <p><strong>As I can solve this?</strong></p>