大家好,我首先介绍了该项目:我开发了一个应用程序,用于通过COM端口接收串行数据。为此,我将Visual Studio 2015与C#和winforms结合使用。
这就是我在winform应用程序中接收数据的方式。
...
//create a Stream for the Port
SerialPort sp = (SerialPort)sender;
//read the incoming data
string indata = sp.ReadExisting();
if (sendDataFlag == 1)//sendDataFlag is used for a "StopShowData" Button
{
//show the data in the RichTextBox
//with the StreamManage i sort the incoming data
this.Invoke((Func<string, bool>)StreamManage, indata);
}
重复该错误的方法:启动应用程序时,我必须单击“开始”按钮以在RTB中显示数据。当我现在刚开始更改应用程序的大小时,我不再通过端口接收数据。我没有收到错误,所以我不知道该怎么办。
我希望有人可以说我该做什么或我可以更改以防止该错误。
怀着友好的祝福
尝试在单独的工作线程上运行从串行端口读取的代码。看来UI线程处理的UI消息可能会阻止您的串行端口读取代码。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句