Tijmen
Tijmen
CC#
Created by Tijmen on 12/6/2024 in #help
Task cancellation in UDPClient.RecieveAsync not triggering
I'm trying to recieve some UDP data, but give up if it hasnt been gotten within 40 ms. I think the recommended way would be to pass in a TaskCancellationToken where the source has had a call to CancelAfter. However the task doesnt appear to be cancelled at all. When i change my approach and use Task.WhenAny, waiting on either udp or Task.Delay it does work correctly.
CancellationTokenSource src = new CancellationTokenSource();

while (true)
{
src.CancelAfter(40);
var len = await udpClient.Client.ReceiveFromAsync(recieveData, remoteEP, src.Token);
src.TryReset();
}
CancellationTokenSource src = new CancellationTokenSource();

while (true)
{
src.CancelAfter(40);
var len = await udpClient.Client.ReceiveFromAsync(recieveData, remoteEP, src.Token);
src.TryReset();
}
When i disconnect the device i'm connecting to it just hangs on RecieveFrom forever. I tried the overloads in UDPClient and in the underlying socket to no avail. Anything im doing wrong?
5 replies
CC#
Created by Tijmen on 4/10/2024 in #help
Visual Studio opening search results in the search dock, not main window
Kinda unrelated to C#, but since a few updates ago Visual Studio started behaving weirdly for me. When i do any type of search, say find references, and open the reference, in the dock where the search is a new text editor window opens. It used to be the case that the main editor window would open that file, and i'd really like that functionality back. Does that ring a bell to anyone?
1 replies
CC#
Created by Tijmen on 12/12/2023 in #help
Inheritance
No description
10 replies
CC#
Created by Tijmen on 11/2/2023 in #help
❔ TargetParameterCountException when trying to create a delegate from a method
No description
7 replies