示例#1
0
 private void btnBegin_Click(object sender, EventArgs e)
 {
     if (btnBegin.Text == "开始")
     {
         if (btnSerial.Text != "打开串口" || btnListen.Text != "开始监听")
         {
             Counter = int.Parse(Tim.Text) / 100;
             if (Counter < 1)
             {
                 Info     = "时间间隔过小";
                 Tim.Text = "1000";
                 Counter  = 10;
             }
             SendTimer.Start(); //开启定时器
             btnBegin.Text = "停止";
         }
         else
         {
             Info = "端口未打开!";
         }
     }
     else
     {
         SendTimer.Stop(); //停止定时器
         btnBegin.Text = "开始";
     }
 }
示例#2
0
        private void SendTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Interlocked.Increment(ref _currentIndex);

            if (_currentIndex <= Tasks.Count)
            {
                Tasks[_currentIndex].Start();

                ProgressAction(_currentIndex, TotalNumberOfTasks);
            }
            else
            {
                SendTimer.Stop();
            }
        }
        private void SendTimer_Tick(object sender, EventArgs e)
        {
            SendTimer.Stop();

            try
            {
                string[] SendMessageContent = SendProtocol.Split(' ');
                for (int i = 0; i < 8; i++)
                {
                    SendByte[i] = Convert.ToByte(SendMessageContent[i], 16);
                }
                serialPort1.Write(SendByte, 0, SendByte.Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show("发送错误");
            }
            SendTimer.Start();
        }
 private void Close_Btn_Click(object sender, EventArgs e)
 {
     serialPort1.Close();
     SendTimer.Stop();
 }
 private void SendTimer_Tick(object sender, EventArgs e)
 {
     SendTimer.Stop();
     serialPort.Write(Sendbytes, 0, 8);
     SendTimer.Start();
 }
示例#6
0
 private void Stop()
 {
     SendTimer.Stop();
     CloudButtonContent = "Push";
 }
 private void Stop()
 {
     SendTimer.Stop();
 }
示例#8
0
 private void button2_Click(object sender, EventArgs e)
 {
     SendTimer.Stop();
 }