From 14ba71005f06592fc552366ef2fb179ae5765e3b Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 2 Sep 2023 16:15:47 +0200 Subject: [PATCH] CheckJobs combined cancelled and completed checks, added standby check --- Tranga/Jobs/JobBoss.cs | 16 ++++++---------- Tranga/Jobs/ProgressToken.cs | 7 ++++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 7248b45..3be3204 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -165,16 +165,7 @@ public class JobBoss : GlobalBase if(jobQueue.Count < 1) continue; Job queueHead = jobQueue.Peek(); - if (queueHead.progressToken.state is ProgressToken.State.Complete) - { - if(queueHead.recurring) - queueHead.ResetProgress(); - jobQueue.Dequeue(); - }else if (queueHead.progressToken.state is ProgressToken.State.Standby) - { - AddJobsToQueue(jobQueue.Peek().ExecuteReturnSubTasks()); - } - else if (queueHead.progressToken.state is ProgressToken.State.Cancelled) + if (queueHead.progressToken.state is ProgressToken.State.Complete or ProgressToken.State.Cancelled) { switch (queueHead) { @@ -187,6 +178,11 @@ public class JobBoss : GlobalBase break; } jobQueue.Dequeue(); + }else if (queueHead.progressToken.state is ProgressToken.State.Standby) + { + Job[] subJobs = jobQueue.Peek().ExecuteReturnSubTasks().ToArray(); + AddJobs(subJobs); + AddJobsToQueue(subJobs); } } } diff --git a/Tranga/Jobs/ProgressToken.cs b/Tranga/Jobs/ProgressToken.cs index 5661403..6624bc6 100644 --- a/Tranga/Jobs/ProgressToken.cs +++ b/Tranga/Jobs/ProgressToken.cs @@ -15,7 +15,7 @@ public class ProgressToken this.cancellationRequested = false; this.increments = increments; this.incrementsCompleted = 0; - this.state = State.Standby; + this.state = State.Complete; } private float GetProgress() @@ -32,6 +32,11 @@ public class ProgressToken state = State.Complete; } + public void Standby() + { + state = State.Standby; + } + public void Start() { state = State.Running;