-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathProgram.cs
39 lines (34 loc) · 1.36 KB
/
Program.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
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace DNTScanner.WindowsService
{
class Program
{
static async Task Main(string[] args)
{
using (var serviceProvider = ApplicationServices.ServiceProvider)
{
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
try
{
var scannerHubClient = serviceProvider.GetRequiredService<IScannerHubClient>();
var scannerService = serviceProvider.GetRequiredService<IScannerService>();
scannerHubClient.RegisterCallbacks(
async (msg) => await scannerService.DetectScanner(msg),
async (newScanConfig) => await scannerService.DoScan(newScanConfig));
await scannerHubClient.StartAsync();
logger.LogInformation("Connection started.");
logger.LogInformation("Press a key to terminate the application ...");
Console.ReadKey();
await scannerHubClient.StopAsync();
}
catch (Exception ex)
{
logger.LogError(ex, "Program terminated.");
}
}
}
}
}