UdpClient.ReceiveAsync correct early termination
问题 Good day. I work with UdpClient and have wrapper upon it. For reading I have asynchronous method: private async Task<byte[]> Receive(UdpClient client, CancellationToken breakToken) { // Выход из async, если произошёл CancellationRequest breakToken.ThrowIfCancellationRequested(); UdpReceiveResult result; try { result = await client.ReceiveAsync().WithCancellation(breakToken); } catch(OperationCanceledException) { // Штатная ситуация ручной остановки Task-а } return result.Buffer; } Where