private void Restart_Button_Click(object sender, EventArgs e) { if (DownCam_ComboBox.SelectedIndex == UpCam_ComboBox.SelectedIndex) { Global.Instance.DisplayText("Up cam can't be the same as downcam"); return; } new Thread(delegate() { if (downVideoCapture.IsRunning()) { downVideoCapture.Close(); } if (upVideoCapture.IsRunning()) { upVideoCapture.Close(); } }).Start(); while (downVideoCapture.IsRunning()) { Global.DoBackgroundWork(); } while (upVideoCapture.IsRunning()) { Global.DoBackgroundWork(); } upVideoCapture.Start(UpCam_ComboBox.SelectedIndex); downVideoCapture.Start(DownCam_ComboBox.SelectedIndex); //save Properties.Settings.Default.DownCam_index = DownCam_ComboBox.SelectedIndex + 1; Properties.Settings.Default.UpCam_index = UpCam_ComboBox.SelectedIndex + 1; Properties.Settings.Default.Save(); }
public void Cleanup(object sender, System.ComponentModel.CancelEventArgs e) { // stop forwarding frames downVideoCapture.FrameCaptureDelegates.Clear(); upVideoCapture.FrameCaptureDelegates.Clear(); Thread.Sleep(100); // shut down cameras if (downVideoCapture.IsRunning()) { downVideoCapture.NoWaitClose(); } if (upVideoCapture.IsRunning()) { upVideoCapture.NoWaitClose(); } }