Unable to cancel async operation using CancellationToken
Hey all, I have a piece of code which attempts to cancel a UDP Recieve call after 5 seconds
3 Replies
This is the code particularly:
I am really going crazy trying to cancel this operation if a result is not recieved within 5 seconds, does anyone know why I'm unable to stop this operation?
https://stackoverflow.com/questions/25683980/timeout-pattern-on-task-based-asynchronous-method-in-c-sharp#26006041
there is some response here for the same questions
Stack Overflow
Timeout pattern on task-based asynchronous method in C#
As far as I know, there're two possible patterns to implement a timeout to task-based asynchronous methods:
Built-in timeout
public Task DoStuffAsync(TimeSpan timeout)
This approach is harder to
@xtreit tried this approach, it seems to still hang for some reason, the
RecieveAsync
itself just completely (but asynchronously) hangs everything