소스 검색

Use Task.WhenAll to handle errors in both tasks.

Previously if there was an exception in the first task that is awaited the second task would not be awaited.
release/3.x.x
Johan x Lindqvist 5 년 전
부모
커밋
ba9ceed7ce
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. +4
    -2
      Source/MQTTnet/Client/MqttClient.cs

+ 4
- 2
Source/MQTTnet/Client/MqttClient.cs 파일 보기

@@ -269,8 +269,10 @@ namespace MQTTnet.Client
await _adapter.DisconnectAsync(Options.CommunicationTimeout, CancellationToken.None).ConfigureAwait(false);
}

await WaitForTaskAsync(_packetReceiverTask, sender).ConfigureAwait(false);
await WaitForTaskAsync(_keepAlivePacketsSenderTask, sender).ConfigureAwait(false);
var receiverTask = WaitForTaskAsync(_packetReceiverTask, sender);
var keepAliveTask = WaitForTaskAsync(_keepAlivePacketsSenderTask, sender);
await Task.WhenAll(receiverTask, keepAliveTask).ConfigureAwait(false);

_logger.Verbose("Disconnected from adapter.");
}


불러오는 중...
취소
저장