我有一个程序,后台工作人员不断读取Windows托管的wifi网络上由arduino发送的udp数据包。从1809更新到Windows 10 1909之后,该程序随机停止工作。
[我安装了wireshark以检查我是否完全接收到任何数据,UPD数据包从arduino IP到端口10001的流量持续不断,但是程序停留在udpclient.receive。
这是后台工作者的代码:
UdpClient udpClient = new UdpClient(10001);
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Parse("192.168.137.4"), 10001);
byte[] receiveBytes;
ardunoPacketTimer.Start();
try
{
while (worker.CancellationPending == false)
{
receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
//When whatever is going wrong happens, the program doesn't get past here
SendArduinoData2Joystick(receiveBytes);
}
}
尝试在添加一些日志记录的同时添加catch语句,因此您不只是丢弃可能发生的异常。