Added ProgressToken state Cancelled
This commit is contained in:
parent
37cf47bc17
commit
0b77dc1172
@ -59,13 +59,15 @@ public abstract class Job : GlobalBase
|
|||||||
public void ResetProgress()
|
public void ResetProgress()
|
||||||
{
|
{
|
||||||
this.progressToken = new ProgressToken(this.progressToken.increments);
|
this.progressToken = new ProgressToken(this.progressToken.increments);
|
||||||
|
this.lastExecution = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
Log($"Cancelling {this}");
|
Log($"Cancelling {this}");
|
||||||
this.progressToken.cancellationRequested = true;
|
this.progressToken.cancellationRequested = true;
|
||||||
this.progressToken.Complete();
|
this.progressToken.Cancel();
|
||||||
|
this.lastExecution = DateTime.Now;
|
||||||
if(subJobs is not null)
|
if(subJobs is not null)
|
||||||
foreach(Job subJob in subJobs)
|
foreach(Job subJob in subJobs)
|
||||||
subJob.Cancel();
|
subJob.Cancel();
|
||||||
|
@ -146,6 +146,20 @@ public class JobBoss : GlobalBase
|
|||||||
jobQueue.Dequeue();
|
jobQueue.Dequeue();
|
||||||
}else if(queueHead.progressToken.state is ProgressToken.State.Standby)
|
}else if(queueHead.progressToken.state is ProgressToken.State.Standby)
|
||||||
AddJobsToQueue(jobQueue.Peek().ExecuteReturnSubTasks());
|
AddJobsToQueue(jobQueue.Peek().ExecuteReturnSubTasks());
|
||||||
|
else if (queueHead.progressToken.state is ProgressToken.State.Cancelled)
|
||||||
|
{
|
||||||
|
switch (queueHead)
|
||||||
|
{
|
||||||
|
case DownloadChapter:
|
||||||
|
RemoveJob(queueHead);
|
||||||
|
break;
|
||||||
|
case DownloadNewChapters:
|
||||||
|
if(queueHead.recurring)
|
||||||
|
queueHead.progressToken.Complete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
jobQueue.Dequeue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ public class ProgressToken
|
|||||||
public int incrementsCompleted { get; set; }
|
public int incrementsCompleted { get; set; }
|
||||||
public float progress => GetProgress();
|
public float progress => GetProgress();
|
||||||
|
|
||||||
public enum State { Running, Complete, Standby }
|
public enum State { Running, Complete, Standby, Cancelled }
|
||||||
public State state { get; private set; }
|
public State state { get; private set; }
|
||||||
|
|
||||||
public ProgressToken(int increments)
|
public ProgressToken(int increments)
|
||||||
@ -41,4 +41,9 @@ public class ProgressToken
|
|||||||
{
|
{
|
||||||
state = State.Complete;
|
state = State.Complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
state = State.Cancelled;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user