Added API.OnStop(). Added ConsoleCancelEvent

This commit is contained in:
EntenKoeniq
2021-12-08 13:45:00 +01:00
parent 250ea7d3f3
commit 652733c715
3 changed files with 32 additions and 4 deletions

View File

@ -5,6 +5,7 @@ namespace CoopServer
{
class Program
{
public static bool ReadyToStop = false;
static void Main(string[] args)
{
try
@ -16,6 +17,15 @@ namespace CoopServer
File.WriteAllText("log.txt", string.Empty);
}
Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
{
if (e.SpecialKey == ConsoleSpecialKey.ControlC)
{
e.Cancel = true;
ReadyToStop = true;
}
};
_ = new Server();
}
catch (Exception e)