https://blog.csdn.net/fengda2870/article/details/51554838
上面的連接給出了提示: 將Invoke變爲BeginInvoke。ui
親測可行。this
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new DataReceived(SerialPort_DataReceived), sender, e); //DataReceived爲代理類型 return; } if (!SerialPortRuning) { SerialPortRuning = true; try { // 接收串口數據 } catch (Exception ex) {
} finally { SerialPortRuning = false; } } }
下面還有一篇關於串口相關的介紹:
C# 串口操做系列(2) – 入門篇,爲何個人串口程序在關閉串口時候會死鎖 ?spa
出處:https://blog.csdn.net/qq_27508477/article/details/87719668.net