logs errors in worker loop

This commit is contained in:
ThatBen 2025-04-03 14:28:23 +02:00
parent b5f3dfe034
commit 2c9f9d1008
No known key found for this signature in database
GPG Key ID: 62C543548433D43E

View File

@ -43,9 +43,9 @@ namespace AutoClient
public void Queue(Action<CodexWrapper> action)
{
if (queue.Count > 2) log.Log("Queue full. Waiting...");
while (queue.Count > 2)
{
log.Log("Queue full. Waiting...");
Thread.Sleep(TimeSpan.FromSeconds(5.0));
}
@ -57,18 +57,26 @@ namespace AutoClient
private void Worker()
{
while (running)
try
{
while (queue.Count == 0) Thread.Sleep(TimeSpan.FromSeconds(5.0));
Action<CodexWrapper> action = w => { };
lock (queueLock)
while (running)
{
action = queue[0];
queue.RemoveAt(0);
}
while (queue.Count == 0) Thread.Sleep(TimeSpan.FromSeconds(5.0));
action(instance);
Action<CodexWrapper> action = w => { };
lock (queueLock)
{
action = queue[0];
queue.RemoveAt(0);
}
action(instance);
}
}
catch (Exception ex)
{
log.Error("Exception in worker: " + ex);
throw;
}
}
}