mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-20 19:59:15 +12:00
Massively improve CPU Usage.
This commit is contained in:
parent
298c2aca4a
commit
80b0e88e1e
3 changed files with 55 additions and 64 deletions
|
@ -1,6 +1,7 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Cli
|
||||
|
@ -10,6 +11,7 @@ namespace HISP.Cli
|
|||
private static StreamWriter sw = null;
|
||||
private static FileStream fs = null;
|
||||
private static string logFile;
|
||||
private static EventWaitHandle shutdownHandle;
|
||||
|
||||
public static bool ShuttingDown = false;
|
||||
public static string BaseDir;
|
||||
|
@ -42,7 +44,7 @@ namespace HISP.Cli
|
|||
|
||||
public static void OnShutdown()
|
||||
{
|
||||
ShuttingDown = true;
|
||||
shutdownHandle.Set();
|
||||
}
|
||||
public static void LogToFile(bool error, string type,string text)
|
||||
{
|
||||
|
@ -125,9 +127,9 @@ namespace HISP.Cli
|
|||
|
||||
Entry.SetShutdownCallback(OnShutdown);
|
||||
Entry.Start();
|
||||
while (!ShuttingDown) { /* Allow asyncronous operations to happen. */ };
|
||||
Task.WaitAll();
|
||||
|
||||
|
||||
shutdownHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
|
||||
shutdownHandle.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue