Exemple #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (m_connected)
     {
         button2.Text = "Connect";
         m_readTh.Abort();
         m_readTh.Join();
         m_readTh = null;
         m_gas.Close();
         m_gas.Dispose();
         m_gas = null;
     }
     else
     {
         PortDefinition pd = comboBox1.SelectedItem as PortDefinition;
         m_gas = pd.Open();
         m_readTh = new Thread(new ThreadStart(ReadThread));
         m_readTh.Start();
         button2.Text = "Disconnect";
     }
     m_connected = !m_connected;
 }
Exemple #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (m_readTh != null && m_readTh.IsAlive)
     {
         m_readTh.Abort();
         m_readTh = null;
     }
     if (m_gas != null)
     {
         m_gas.Close();
         m_gas.Dispose();
         m_gas = null;
     }
 }