#40 task timeout criteria
This commit is contained in:
parent
1f3ac41b30
commit
87eade10cf
@ -124,7 +124,7 @@ public class TaskManager
|
||||
foreach (KeyValuePair<DownloadChapterTask,Task> removeTask in _runningDownloadChapterTasks)
|
||||
{
|
||||
if (removeTask.Key.GetType() == typeof(DownloadChapterTask) &&
|
||||
DateTime.Now.Subtract(removeTask.Key.executionStarted) > TimeSpan.FromMinutes(10))//TODO better way to check if task has failed?
|
||||
DateTime.Now.Subtract(removeTask.Key.lastChange) > TimeSpan.FromMinutes(3))//3 Minutes since last update to task -> remove
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removing failed task {removeTask}.");
|
||||
removeTask.Value.Dispose();
|
||||
|
@ -23,7 +23,7 @@ public abstract class TrangaTask
|
||||
[Newtonsoft.Json.JsonIgnore]public ExecutionState state { get; set; }
|
||||
[Newtonsoft.Json.JsonIgnore]public float progress { get; protected set; }
|
||||
[Newtonsoft.Json.JsonIgnore]public DateTime nextExecution => lastExecuted.Add(reoccurrence);
|
||||
[Newtonsoft.Json.JsonIgnore]public DateTime executionStarted { get; protected set; }
|
||||
[Newtonsoft.Json.JsonIgnore]public DateTime executionStarted { get; private set; }
|
||||
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public DateTime executionApproximatelyFinished => this.progress != 0
|
||||
@ -33,6 +33,8 @@ public abstract class TrangaTask
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public TimeSpan executionApproximatelyRemaining => this.executionApproximatelyFinished.Subtract(DateTime.Now);
|
||||
|
||||
[Newtonsoft.Json.JsonIgnore]public DateTime lastChange { get; protected set; }
|
||||
|
||||
public enum ExecutionState
|
||||
{
|
||||
Waiting,
|
||||
@ -47,11 +49,13 @@ public abstract class TrangaTask
|
||||
this.task = task;
|
||||
this.progress = 0f;
|
||||
this.executionStarted = DateTime.Now;
|
||||
this.lastChange = DateTime.Now;
|
||||
}
|
||||
|
||||
public float IncrementProgress(float amount)
|
||||
{
|
||||
this.progress += amount;
|
||||
this.lastChange = DateTime.Now;
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ public class DownloadChapterTask : TrangaTask
|
||||
public new float IncrementProgress(float amount)
|
||||
{
|
||||
this.progress += amount;
|
||||
this.lastChange = DateTime.Now;
|
||||
parentTask?.IncrementProgress(amount);
|
||||
return this.progress;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class DownloadNewChaptersTask : TrangaTask
|
||||
public new float IncrementProgress(float amount)
|
||||
{
|
||||
this.progress += amount / this.childTaskAmount;
|
||||
this.lastChange = DateTime.Now;
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user