private void GliderScoreRemoteForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     GliderScoreWindowScraperThread.Stop();
     writerThread.Stop();
     telemetryThread.Stop();
     timerThread.Stop();
 }
        private void GliderScoreRemoteForm_Load(object sender, EventArgs e)
        {
            tbPollingFrequency.Value = Properties.Settings.Default.PollingFrequency;
            tbBroadcastDelay.Value   = Properties.Settings.Default.BroadcastDelay;
            tbUDPTimerPort.Text      = Properties.Settings.Default.UDPTimerPort.ToString();
            tbUDPTelemetryPort.Text  = Properties.Settings.Default.UDPTelemetryPort.ToString();

            // initialize the queue
            queue        = new BlockingCollection <DeferredData>();
            writerThread = new DeferredDataWriterThread(ref queue);

            // thread start order is important
            timerThread.Start(Properties.Settings.Default.UDPTimerPort, UDPTimerReadCallback);
            telemetryThread.Start(Properties.Settings.Default.UDPTelemetryPort, UDPTelemetryReadCallback);
            writerThread.Start();

            GliderScoreWindowScraperThread.WaitInterval = 1000 / tbPollingFrequency.Value;
            GliderScoreWindowScraperThread.Start(TimeCallback, LBSelectedTextCallback);

            string selectedTimerComPort = Properties.Settings.Default.TimerComPort;

            cbTimerComPort_DropDown(null, null); // load up the list of current com ports
            if (cbTimerComPort.Items.Contains(selectedTimerComPort))
            {
                cbTimerComPort.SelectedItem = selectedTimerComPort;
            }
            else
            {
                cbTimerComPort.SelectedItem = "<none>";
            }
            cbTimerComPort.DropDown += cbTimerComPort_DropDown; // this will refresh the list when 'dropped'
        }