You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Worker.cs 837B

12345678910111213141516171819202122232425262728
  1. using Microsoft.Extensions.Logging;
  2. using TelpoPush.Worker.ThirdSsl.Handlers;
  3. namespace TelpoPush.Worker.ThirdSsl
  4. {
  5. public class Worker : BackgroundService
  6. {
  7. private readonly IHostEnvironment _env;
  8. private readonly ILogger<Worker> _logger;
  9. KafkaSubscribe _kafkaSubscribe;
  10. public Worker(ILogger<Worker> logger, IHostEnvironment env, KafkaSubscribe kafkaSubscribe)
  11. {
  12. _env = env;
  13. _logger = logger;
  14. _kafkaSubscribe = kafkaSubscribe;
  15. }
  16. protected override async Task ExecuteAsync(CancellationToken stoppingToken)
  17. {
  18. while (!stoppingToken.IsCancellationRequested)
  19. {
  20. await _kafkaSubscribe.SubscribeAsync();
  21. await Task.Delay(30000, stoppingToken);
  22. }
  23. }
  24. }
  25. }