当我在运行时更改应用程序的大小时,为什么要停止我的数据传输?
Why stop my data transmission when i change the size of my application at runtime?
您好,首先是关于项目的信息:我开发了一个应用程序来通过 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 中显示数据。当我现在在开始后直接更改应用程序的大小时,我不再通过端口接收数据。我没有收到错误,所以我不知道我必须做什么。
我希望有人能告诉我我必须做什么或者我可以改变什么来防止这个错误。
Sniffi友情祝福
尝试 运行 在单独的工作线程上从串行端口读取的代码。 UI 线程处理的 UI 消息可能会阻止您的串口读取代码。
您好,首先是关于项目的信息:我开发了一个应用程序来通过 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 中显示数据。当我现在在开始后直接更改应用程序的大小时,我不再通过端口接收数据。我没有收到错误,所以我不知道我必须做什么。
我希望有人能告诉我我必须做什么或者我可以改变什么来防止这个错误。
Sniffi友情祝福
尝试 运行 在单独的工作线程上从串行端口读取的代码。 UI 线程处理的 UI 消息可能会阻止您的串口读取代码。