Created
September 1, 2023 10:11
-
-
Save bjoerntx/585d7efe0660a87fbcd18804f22cd157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BackgroundGenerator : IHostedService | |
{ | |
private readonly ILogger<BackgroundGenerator> logger; | |
private readonly IWorker worker; | |
public BackgroundGenerator(ILogger<BackgroundGenerator> logger, | |
IWorker worker) | |
{ | |
this.logger = logger; | |
this.worker = worker; | |
} | |
public async Task StartAsync(CancellationToken cancellationToken) | |
{ | |
await worker.DoWork(cancellationToken); | |
} | |
public Task StopAsync(CancellationToken cancellationToken) | |
{ | |
logger.LogInformation("Generator worker stopping"); | |
return Task.CompletedTask; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment