mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-06-18 20:59:05 +00:00
Drastically increase log processing speed
This commit is contained in:
parent
3f892c6a37
commit
e9f0e75d60
1 changed files with 8 additions and 8 deletions
|
@ -100,14 +100,20 @@ public class LogHandler(string logPath)
|
||||||
{
|
{
|
||||||
CheckGameProcessState();
|
CheckGameProcessState();
|
||||||
|
|
||||||
if (_reader?.ReadLine() is { } line)
|
List<string> lines = new List<string>();
|
||||||
|
while (_reader.ReadLine() is { } line)
|
||||||
|
{
|
||||||
|
lines.Add(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
// start new thread to handle log entry
|
// start new thread to handle log entry
|
||||||
var thread = new Thread(() => HandleLogEntry(line));
|
var thread = new Thread(() => HandleLogEntry(line));
|
||||||
thread.Start();
|
thread.Start();
|
||||||
// Console.WriteLine(line);
|
// Console.WriteLine(line);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Wait for new lines to be written to the log file
|
// Wait for new lines to be written to the log file
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
@ -131,14 +137,8 @@ public class LogHandler(string logPath)
|
||||||
_reader?.Close();
|
_reader?.Close();
|
||||||
_fileStream?.Close();
|
_fileStream?.Close();
|
||||||
|
|
||||||
// Wait for the log file to be written to
|
|
||||||
Thread.Sleep(3000);
|
|
||||||
|
|
||||||
_fileStream = new FileStream(_logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
_fileStream = new FileStream(_logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
_reader = new StreamReader(_fileStream);
|
_reader = new StreamReader(_fileStream);
|
||||||
|
|
||||||
// Skip all the startup junk
|
|
||||||
while (_reader.ReadLine() is { } line) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_gameProcessState = newGameProcessState;
|
_gameProcessState = newGameProcessState;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue