日期:2014-05-18 浏览次数:21127 次
private void timer1_Tick_1(object sender, EventArgs e)
        {
            try
            {
                System.Threading.Thread timerThread = new System.Threading.Thread(new System.Threading.ThreadStart(TimerMethod));
                    timerThread.Start();
                //周期性将临时数据存入历史数据库
            }
            catch (Exception exp)
            {
                timer1.Stop();
            }
        }
public void TimerMethod()
        {
            try
            {
                //清除临时数据
                using (SerialPort port = new SerialPort())
                {
                    //设置串口 
                    port.Open();
                    //从串口读数据
                    port.Close();
                            
                    if (con.State == ConnectionState.Open)
                    {
                        //将实时数据写入数据库
                        //***********显示实时数值                           
                        // ************刷新控件状态
                        //************判断是否报警
                       }                    
                }
            }
            catch (Exception exp)
            {
                timer1.Stop();
                System.Threading.Thread.CurrentThread.Abort();
            }
        }