void UpdateCapture(object sender, UpdatePictureArgs e) { if (_doUpdateCapture != false) { return; } _doUpdateCapture = true; if (e.Exception == null) { byte[] buf = e.Bitmap; if (buf != null && !_wb.CheckAccess()) { _wb.Dispatcher.InvokeAsync(() => { _wb.WritePixels(new Int32Rect(0, 0, _wb.PixelWidth, _wb.PixelHeight), buf, _wb.BackBufferStride, 0); } ); } _bindingP.WinTitle = _defWinTitle + "[" + e.FrameRate + "]"; //pic.Source = _wb; } else { _exception = e.Exception; _isRunDetector = false; if (!CheckAccess()) { Dispatcher.InvokeAsync(() => { Close(); } ); } } _doUpdateCapture = false; }