コード例 #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _stoppingTokenSource = CancellationTokenSource.CreateLinkedTokenSource(stoppingToken);

            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    var eventEnvelope = await _eventStream.DequeueAsync();

                    await HandleEvent(eventEnvelope, stoppingToken);
                }
                catch (Exception ex)
                {
                    _logger.LogCritical("An unhandled exception occurred, and the event stream handler will be stopped. {@exception}", ex);
                    _currentTask = null;
                    await StopAsync(default);