int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen) { App.Current.Dispatcher.BeginInvoke( new MethodInvokerDelegate(delegate() { try { CurrentImage = BitmapSource.Create(width, height, 96, 96, PixelFormats.Rgb24, null, pBuffer, BufferLen, stride); } catch { } } )); return 0; }