Closed YorkWong1995 closed 11 months ago
In debug mode , sometimes , reply.Result.buffer is now at first , but when it runs reply.Result.Buffer != null, reply.Result.buffer got data, it is not null any more. and i do not find the reason, too. In this situation, wireshark will get the return package.
It seems receiveasync is Asynchronous method so when i want to compare reply.result.buffer with null reply is receiving data, meanwhile , i want to get the reply value to do comparation
@YorkWong1995 this is not related to the library. You must understand how asynchronous methods work. You must wait for it to finish before doing anything with the result. From this snippet, it seems like you are not using the library properly.
I also used if (await Task.WhenAny(reply, Task.Delay(socketTx.Client.ReceiveTimeout)).ConfigureAwait(false) == reply) to wait the method finished. but in debug mode, this condition is never satisfy. the reply status is always waitingforactivation, but wireshark already caught the return package.
In another word, i used var ret = await Task.WhenAny(reply, Task.Delay(socketTx.Client.ReceiveTimeout)).ConfigureAwait(false); the status of ret is always different from the reply‘s
After Task
can you comment the whole method?
This problem is not related to library
I wanna to got the data in UdpReceiveResult.Result.buffer in SendGvcpCommand function. but When i got reply from socket, and run reply.Result.Buffer != null , it suddenly crashed with no exception. use wireshark there is no any data.![cap](https://user-images.githubusercontent.com/54474676/205200002-f24f3239-36ef-4da2-ae43-ebc17fea8c27.JPG)
Do u know what will lead to this problem here is my code.
thanks in advance.