void SerialPort_Result(object sender, SerialPortEvents e) { this.Invoke(new MethodInvoker(() => { //处理结果 rtbResult.Text += Encoding.GetEncoding("GB2312").GetString(e.BufferData); })); }
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(); //})); }
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(); })); }