-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
45 lines (35 loc) · 1.18 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
40
41
42
43
44
45
using ArmstrongServer.Models.ConfigModels;
using ArmstrongServer.Models;
using ArmstrongServer.Helpers;
namespace ArmstrongServer
{
public static class Program
{
public static List<Server> Servers { get; set; }
public static async Task Main(string[] args)
{
Initialization();
var cancellationTokenSource = new CancellationTokenSource();
CancellationToken cancellationToken = cancellationTokenSource.Token;
var serverTasks = new List<Task>();
foreach (var server in Servers)
{
var task = Task.Run(() => server.Start(cancellationToken), cancellationToken);
serverTasks.Add(task);
}
Console.WriteLine("Starting server tasks...");
Console.WriteLine("Press Enter to abort polling.");
Console.ReadLine();
Console.WriteLine("Stopping server tasks...");
cancellationTokenSource.Cancel();
await Task.WhenAll(serverTasks);
Console.WriteLine("All server tasks have completed.");
}
public static void Initialization()
{
AppSettings.Initialization();
Servers = ServerHelper.GetServerList(AppSettings.AppGeneralSettings.ServerProps);
SayHelloWorld.Say();
}
}
}