多个c#SerialPorts似乎挂起了我的应用程序

时间:2016-09-27 09:42:57

标签: windows winforms serial-port

我在Windows窗体中有一个连接到16个串行端口的应用程序。我用于每个人的结构是:

private void Serial_CodeNip_15_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
    string S = Serial_CodeNip_15.ReadExisting();
    myProcess(S);
}
public delegate void del_myProcess(string stringa);
private void myProcess(string stringa)
{
    if (this.InvokeRequired)
    {
        del_myProcess tmp = new del_myProcess(myProcess);
        try
        {
            this.Invoke(tmp, stringa);
        }
        catch (Exception)
        {
        }
    }
    else
    {
        // my code here
    }
}

从条形码阅读器接收数据,工作正常,直到更多读者(最多6个或7个)同时开始阅读。在这种情况下,我的应用程序倾向于挂起,并且所有读者都表示难以从串行输入缓冲区捕获数据。这是从串行端口读取异步数据的正确方法,还是另一种简单的方法。我注意到使用少数串行端口没有问题。

提前感谢您的帮助

0 个答案:

没有答案