Latency update and threading fixes.

This commit is contained in:
Sardelka
2022-06-01 19:05:45 +08:00
parent 87b9a67d0b
commit 42d057e2c5
4 changed files with 31 additions and 29 deletions

View File

@ -7,7 +7,7 @@ using System.Diagnostics;
namespace RageCoop.Core.Logging
{
public class Logger
public class Logger :IDisposable
{
/// <summary>
@ -20,13 +20,14 @@ namespace RageCoop.Core.Logging
private string Buffer="";
private Thread LoggerThread;
private bool Stopping=false;
public Logger(bool overwrite=true)
{
if (File.Exists(LogPath)&&overwrite) { File.Delete(LogPath); }
LoggerThread=new Thread(() =>
{
while (true)
while (!Stopping)
{
Flush();
Thread.Sleep(1000);
@ -132,5 +133,10 @@ namespace RageCoop.Core.Logging
}
}
public void Dispose()
{
Stopping=true;
LoggerThread?.Join();
}
}
}