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
RecieveAsync CancellationTokenSource cts = new CancellationTokenSource();
ValueTask<int> numBytesReceived = sock.ReceiveAsync(res, SocketFlags.None, cts.Token);
cts.CancelAfter(5000);
await numBytesReceived;
Array.Resize(ref res, numBytesReceived.Result);