Ejemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var semaphoreSlim = new SemaphoreSlim(10, 10);

            while (!stoppingToken.IsCancellationRequested)
            {
                await foreach (var slackEvent in _eventStorage.ConsumeAllEventsAsync(stoppingToken))
                {
                    await semaphoreSlim.WaitAsync(stoppingToken);

                    _ = HandleEventInBackground(slackEvent, semaphoreSlim, stoppingToken);
                }

                await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
            }
        }