-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestAsyncSonar.cs
50 lines (41 loc) · 1.35 KB
/
TestAsyncSonar.cs
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
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace WorkerService
{
internal class TestAsyncSonar : IHostedService
{
#region Const
private const int TIMER_DELAY = 2000;
private const int TIMER_PERIODE = 60 * 1000;
#endregion
#region Fields
private readonly ILogger<TestAsyncSonar> logger;
private readonly Timer timer;
#endregion
#region C'tor
internal TestAsyncSonar(ILogger<TestAsyncSonar> logger)
{
this.logger = logger;
this.logger.LogInformation("SystemStatus provider is ready...");
}
#endregion
#region IHostedService
public Task StartAsync(CancellationToken cancellationToken)
{
this.timer.Change(TIMER_DELAY, TIMER_PERIODE);
logger.LogInformation("Periodic system status provider started...");
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
this.timer.Change(Timeout.Infinite, Timeout.Infinite);
logger.LogInformation("Periodic system status provider stopped...");
return Task.CompletedTask;
}
#endregion
}
}