public async Task ConnectAsync(TimeSpan timeout)
 {
     try
     {
         await _channel.ConnectAsync().TimeoutAfter(timeout).ConfigureAwait(false);
     }
     catch (TaskCanceledException)
     {
         throw;
     }
     catch (OperationCanceledException)
     {
         throw;
     }
     catch (MqttCommunicationTimedOutException)
     {
         throw;
     }
     catch (MqttCommunicationException)
     {
         throw;
     }
     catch (Exception exception)
     {
         throw new MqttCommunicationException(exception);
     }
 }
        public async Task ConnectAsync(MqttClientOptions options, TimeSpan timeout)
        {
            var task = _channel.ConnectAsync(options);

            if (await Task.WhenAny(Task.Delay(timeout), task) != task)
            {
                throw new MqttCommunicationTimedOutException();
            }
        }
Ejemplo n.º 3
0
 public async Task ConnectAsync(TimeSpan timeout)
 {
     await ExecuteAndWrapExceptionAsync(() => _channel.ConnectAsync().TimeoutAfter(timeout));
 }