Example #1
0
        private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Clean up objects
            try
            {
                if (tetTrackStatus.IsConnected)
                {
                    if (tetTrackStatus.IsTracking)
                    {
                        tetTrackStatus.Stop();
                    }
                    tetTrackStatus.Disconnect();
                }

                if (tetCalibProc.IsConnected)
                {
                    if (tetCalibProc.IsCalibrating)
                    {
                        tetCalibProc.InterruptCalibration();
                    }
                    tetCalibProc.Disconnect();
                }

                // TODO: TetCalibPlot.Disconnect() is always failing
                try
                {
                    if (tetCalibPlot.IsConnected)
                    {
                        tetCalibPlot.Disconnect();
                    }
                }
                catch {}

                if (tetClient.IsConnected)
                {
                    if (tetClient.IsTracking)
                    {
                        tetClient.StopTracking();
                    }
                    tetClient.Disconnect();
                }

                serviceBrowser.Stop();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }