public MainWindow() { Move.Init(); PortIO.Init(); capturing = false; specCapturing = true; moving = false; acquiring = false; acquire = false; getTemp = true; InitializeComponent(); ///////////////////////////////// monitor.XLabel = "wavenumber/cm-1"; ///////////////////////////////// if (!Ccd.Init()) { MessageBox.Show("CCD初始化失败", this.Title, MessageBoxButton.OK, MessageBoxImage.Error); startStopCapture.IsEnabled = false; autoSpex.IsEnabled = false; getTemp = false; } double t; if (!double.TryParse(ConfigurationManager.AppSettings["spexPos"], out t)) { SpexPos = 0; } else { SpexPos = t; } getTempThread = new Thread(new ThreadStart( () => { while (getTemp) { Thread.Sleep(500); this.Dispatcher.BeginInvoke((ThreadStart) delegate() { if (!temperature.IsFocused) { temperature.Content = (Ccd.GetTemp() / 100.0).ToString(); } }); } })); getTempThread.Start(); }
private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (capturing) { capturing = false; getFrameThread.Join(); } if (getTemp) { getTemp = false; getTempThread.Join(); } if (moving) { Move.Stop(); moveThread.Join(); moving = false; moveProgressThread.Join(); } saveConfig("spexPos", SpexPos.ToString()); PortIO.Uninit(); Ccd.Uninit(); }