예제 #1
0
        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();
            }
        }
예제 #2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _startTask = _depot.Start(cancellationToken);

            return(_startTask.IsCompleted
                ? _startTask
                : TaskUtil.Completed);
        }
예제 #3
0
        public static async Task Start(this IBusDepot depot, TimeSpan timeout)
        {
            using var cancellationTokenSource = new CancellationTokenSource(timeout);

            await depot.Start(cancellationTokenSource.Token).ConfigureAwait(false);
        }