-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackgroundGenerator.cs
More file actions
31 lines (27 loc) · 865 Bytes
/
BackgroundGenerator.cs
File metadata and controls
31 lines (27 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Threading;
using System.Threading.Tasks;
namespace BackgroundTask.MailMerge
{
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;
}
}
}