Esempio n. 1
0
        public async Task HandleAsync()
        {
            var thresholdDate = DateTime.UtcNow.AddDays(-31);

            var animesToUpdate = await _animeRepository.GetOlderThanModifiedDate(thresholdDate, _batchSize);

            var publishTasks = animesToUpdate.Select(
                (a, i) => _animeUpdatePublisher.PublishAnimeUpdateAsync(
                    new UpdateAnimeMessage {
                Id = a.Id, MalId = a.MalId
            },
                    i * _delayBetweenMessages
                    )
                );

            await Task.WhenAll(publishTasks);
        }