-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
62 lines (55 loc) · 1.65 KB
/
Program.cs
File metadata and controls
62 lines (55 loc) · 1.65 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using Microsoft.Extensions.Logging;
namespace veeam_task
{
class Program
{
private static int KEY_CHECK_MILLIS = 300;
public static void PressQToExit(int exitCode)
{
Console.WriteLine("Press the Q key to exit.");
do
{
while (!Console.KeyAvailable)
{
Thread.Sleep(KEY_CHECK_MILLIS);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Q);
System.Environment.Exit(exitCode);
}
static void Main(string[] args)
{
Console.WriteLine("Program has started...");
var loggerFactory = LoggerFactory.Create(builder =>
builder.SetMinimumLevel(LogLevel.Debug)
.AddConsole()
.AddDebug()
);
var managerInputLogger = loggerFactory.CreateLogger<ManagerInput>();
ManagerInput mInput;
try
{
mInput = ManagerInput.parseInput(args, managerInputLogger);
}
catch
{
PressQToExit(1);
return;
}
ProcessLifetimeManager manager = new ProcessLifetimeManager(
mInput,
loggerFactory.CreateLogger<ProcessLifetimeManager>()
);
manager.manageLifetime();
PressQToExit(1);
}
}
}