// frame pump void PumpFrames() { // Create capture buffer. byte[] YPx = new byte[(int)cam.PreviewResolution.Width * (int)cam.PreviewResolution.Height]; try { PhotoCamera phCam = (PhotoCamera)cam; while (pumpFrames) { pauseFramesEvent.WaitOne(); // Copies the current viewfinder frame into a buffer for further manipulation. phCam.GetPreviewBufferY(YPx); // DO STUFF HERE m_d3dInterop.update(YPx, (int)cam.PreviewResolution.Width, (int)cam.PreviewResolution.Height); pauseFramesEvent.Reset(); } } catch (Exception e) { this.Dispatcher.BeginInvoke(delegate() { // Display error message. txtDebug.Text = e.Message; }); } }