From f287bd4d1d25ebca2fdcb1e6dcafdcc8d763b14e Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Wed, 20 Sep 2017 08:32:36 +0200 Subject: [PATCH] Fix TimeoutAfter again --- MQTTnet.Core/Internal/TaskExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MQTTnet.Core/Internal/TaskExtensions.cs b/MQTTnet.Core/Internal/TaskExtensions.cs index 38513a0e..f9428abc 100644 --- a/MQTTnet.Core/Internal/TaskExtensions.cs +++ b/MQTTnet.Core/Internal/TaskExtensions.cs @@ -12,7 +12,7 @@ namespace MQTTnet.Core.Internal var timeoutTask = Task.Delay(timeout); var finishedTask = await Task.WhenAny(timeoutTask, task).ConfigureAwait(false); - if (finishedTask == timeoutTask || task.IsCanceled) + if (finishedTask == timeoutTask) { throw new MqttCommunicationTimedOutException(); } @@ -24,7 +24,7 @@ namespace MQTTnet.Core.Internal if (task.IsFaulted) { - throw new MqttCommunicationException(task.Exception); + throw new MqttCommunicationException(task.Exception.GetBaseException()); } ////return TimeoutAfter(task.ContinueWith(t => 0), timeout); @@ -47,7 +47,7 @@ namespace MQTTnet.Core.Internal if (task.IsFaulted) { - throw new MqttCommunicationException(task.Exception); + throw new MqttCommunicationException(task.Exception.GetBaseException()); } return task.Result;