我想在读取数据,并比较之后,清除刚才收到的数据,再执行下一条指令。
那么在哪里清除呢?怎么做?
接收数据: private void Comm_DataReceived(object sender, SerialDataReceivedEventArgs e){}
private void Comm_DataReceived(object sender, SerialDataReceivedEventArgs e) { int n = comm.BytesToRead; byte[] buf = new byte[n]; comm.Read(buf, 0, n); this.Invoke((EventHandler)(delegate { builder.Append(Encoding.UTF8.GetString(buf)); this.textBox1.AppendText(builder.ToString()); }));