Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Worker ExecuteAsync with IEventProcessor
public class Worker : BackgroundService
{
private readonly IEventProcessor _eventProcessor;
private readonly ILogger<Worker> _logger;
public Worker(IEventProcessor eventProcessor, ILogger<Worker> logger)
{
_eventProcessor = eventProcessor;
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await _eventProcessor.Process(stoppingToken);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.