Optimize waiting process for keeping the process running (replace while loop with EventWaitHandle)

This commit is contained in:
ChronosX88 2020-07-19 15:10:14 +04:00
parent 0f15340065
commit 48d27401ae
2 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.config.toml /.config.toml
bin bin
obj obj
/.plugins

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading;
using CommandLine; using CommandLine;
using Nett; using Nett;
using Zirconium.Core.Logging; using Zirconium.Core.Logging;
@ -12,7 +13,7 @@ namespace Zirconium.Core
} }
class Program class Program
{ {
private static bool keepRunning = true; private static EventWaitHandle wailtHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
static void Main(string[] args) static void Main(string[] args)
{ {
@ -45,9 +46,9 @@ namespace Zirconium.Core
{ {
e.Cancel = true; e.Cancel = true;
app.Destroy(); app.Destroy();
keepRunning = false; wailtHandle.Set();
}; };
while(keepRunning) {} wailtHandle.WaitOne();
} }
} }
} }