// Close current file private void CloseVideoSource() { Camera camera = cameraWindow.Camera; if (camera != null) { // detach camera from camera window cameraWindow.Camera = null; // signal camera to stop camera.SignalToStop(); // wait for the camera camera.WaitForStop(); //timer.Stop(); camera = null; } }
// Close current file private void CloseVideoSource() { Camera camera = cameraWindow.Camera; if (camera != null) { // detach camera from camera window cameraWindow.Camera = null; Application.DoEvents(); // signal camera to stop camera.SignalToStop(); // wait for the camera // camera.WaitForStop(); // wait 5 seconds until camera stops for (int i = 0; (i < 50) && (camera.IsRunning); i++) { Thread.Sleep(100); } if (camera.IsRunning) { try { camera.Stop(); } catch (Exception) { } } camera = null; if (mMotionDetector != null) { mMotionDetector.Reset(); } } this.StopCapture(); }