-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorker.cs
More file actions
39 lines (34 loc) · 820 Bytes
/
Worker.cs
File metadata and controls
39 lines (34 loc) · 820 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
32
33
34
35
36
37
38
39
using Microsoft.Extensions.Logging;
using System.Threading;
using System.Threading.Tasks;
using tx_wp_api;
namespace BackgroundTask.MailMerge
{
public class Worker : IWorker
{
private readonly ILogger<Worker> logger;
//private int number = 0;
public Worker(ILogger<Worker> logger)
{
this.logger = logger;
}
public async Task DoWork(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
ProcessingRequest request = new ProcessingRequest(null);
if (request.Id == null)
{
logger.LogInformation("No request found in queue");
await Task.Delay(1000, cancellationToken);
continue;
}
else
{
TextControlProcessing.Merge(request);
logger.LogInformation("Request found - executing worker");
}
}
}
}
}