/// <inheritdoc /> protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await Task.Delay(TimeSpan.FromSeconds(_settingsService.GenerationCheckInterval), stoppingToken).ConfigureAwait(false); if (IsShouldGeneratePersons && MaxPersonsToGenerate > 0) { var personsToGenerate = RandomUtility.InRange(1, MaxPersonsToGenerate + 1); _taskQueue.QueueBackgroundWorkItem(async token => { if (!token.IsCancellationRequested) { await OnGenerateBunchOfPersons(token, personsToGenerate).ConfigureAwait(false); } }); } else { _logger.LogInformation($"Generation is not required, {nameof(IsShouldGeneratePersons)}: {IsShouldGeneratePersons}, {nameof(MaxPersonsToGenerate)}: {MaxPersonsToGenerate}"); } } }