public async Task StartAsync(CancellationToken cancellationToken) { await ResetRabbitMq(); var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); var registration = cancellationToken.Register(() => cancellationTokenSource.Cancel()); try { _logger.LogInformation("Starting"); await _busDepot.Start(cancellationTokenSource.Token); _logger.LogInformation("Started"); } catch (Exception e) { _logger.LogError(e, "Start Faulted"); throw; } finally { await registration.DisposeAsync(); } }
public Task StartAsync(CancellationToken cancellationToken) { _startTask = _depot.Start(cancellationToken); return(_startTask.IsCompleted ? _startTask : TaskUtil.Completed); }
public static async Task Start(this IBusDepot depot, TimeSpan timeout) { using var cancellationTokenSource = new CancellationTokenSource(timeout); await depot.Start(cancellationTokenSource.Token).ConfigureAwait(false); }