using TelpoPush.WanJiaAn.Worker.Handlers; namespace TelpoPush.WanJiaAn.Worker { public class Worker : BackgroundService { private readonly ILogger _logger; KafkaSubscribe _kafkaSubscribe; public Worker(ILogger logger, KafkaSubscribe kafkaSubscribe) { _logger = logger; _kafkaSubscribe = kafkaSubscribe; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await _kafkaSubscribe.SubscribeAsync(); await Task.Delay(1000, stoppingToken); } } } }