Example #1
0
 void SerialPort_Result(object sender, SerialPortEvents e)
 {
     this.Invoke(new MethodInvoker(() => {
         //处理结果
         rtbResult.Text += Encoding.GetEncoding("GB2312").GetString(e.BufferData);
     }));
 }
Example #2
0
 void SerialPort_Send(object sender, SerialPortEvents e)
 {
     //this.Invoke(new MethodInvoker(() =>
     //{
     //    long sendCount = Convert.ToInt64(lbSendCount.Text);
     //    if (e.BufferData != null)
     //    {
     //        sendCount += e.BufferData.Length;
     //    }
     //    lbSendCount.Text = sendCount.ToString();
     //}));
 }
Example #3
0
 void SerialPort_Received(object sender, SerialPortEvents e)
 {
     this.Invoke(new MethodInvoker(() =>
     {
         long receivedCount = Convert.ToInt64(lbReceivedCount.Text);
         if (e.BufferData != null)
         {
             receivedCount += e.BufferData.Length;
         }
         lbReceivedCount.Text = receivedCount.ToString();
     }));
 }