mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Fix crashes if task is not finished yet.
This commit is contained in:
@@ -143,9 +143,21 @@ public static class Tranga
|
||||
Log.Debug($"AfterWork {worker}");
|
||||
if (RunningWorkers.TryGetValue(worker, out Task<BaseWorker[]>? task))
|
||||
{
|
||||
BaseWorker[] newWorkers = task.Result;
|
||||
Log.Debug($"{worker} created {newWorkers.Length} new Workers.");
|
||||
AddWorkers(newWorkers);
|
||||
Log.Debug($"Waiting for Children to exit {worker}");
|
||||
task.Wait();
|
||||
if (task.IsCompleted)
|
||||
{
|
||||
try
|
||||
{
|
||||
BaseWorker[] newWorkers = task.Result;
|
||||
Log.Debug($"{worker} created {newWorkers.Length} new Workers.");
|
||||
AddWorkers(newWorkers);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
}else Log.Warn($"Children failed: {worker}");
|
||||
}
|
||||
RunningWorkers.Remove(worker, out _);
|
||||
callback?.Invoke();
|
||||
|
Reference in New Issue
Block a user