提问人:Aditya Desai 提问时间:8/4/2023 更新时间:8/4/2023 访问量:36
无法更新 AsyncCallback 方法中的 date 属性
unable to update the date property in AsyncCallback method
问:
无法更新 Date 属性 更新 Date 属性
这是我面临的问题的代码片段
public DateTime LastReceivedImplicitMessage { get; set;
var asyncResult = udpClientReceive.BeginReceive( new AsyncCallback(ReceiveCallbackClass1), s);
private void ReceiveCallbackClass1 (IAsyncResult ar) { 尝试 {
UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u;
if (udpClientReceiveClosed)
return;
u.BeginReceive(new AsyncCallback(ReceiveCallbackClass1), (UdpState)(ar.AsyncState));
System.Net.IPEndPoint e = (System.Net.IPEndPoint)((UdpState)(ar.AsyncState)).e;
Byte[] receiveBytes = u.EndReceive(ar, ref e);
// EndReceive worked and we have received data and remote endpoint
if (receiveBytes.Length > 20)
{
//Get the connection ID
uint connectionID = (uint)(receiveBytes[6] | receiveBytes[7] << 8 | receiveBytes[8] << 16 | receiveBytes[9] << 24);
if (connectionID == connectionID_T_O)
{
ushort headerOffset = 0;
if (T_O_RealTimeFormat == RealTimeFormat.Header32Bit)
headerOffset = 4;
if (T_O_RealTimeFormat == RealTimeFormat.Heartbeat)
headerOffset = 0;
for (int i = 0; i < receiveBytes.Length - 20 - headerOffset; i++)
{
T_O_IOData[i] = receiveBytes[20 + i + headerOffset];
}
//Console.WriteLine(T_O_IOData[0]);
}
}
LastReceivedImplicitMessage = DateTime.Now;
}
catch (Exception ex) { }
}
“LastReceivedImplicitMessage”未使用 datetime.now 更新
答: 暂无答案
评论