Tasks are now stored separately in Hashset

Created Dict<Publication, Chapter[]> _chapterCollection for added chapters.
This commit is contained in:
glax 2023-05-18 19:25:46 +02:00
parent 039154dd53
commit 943ce98f38

View File

@ -2,12 +2,14 @@
public class TaskManager public class TaskManager
{ {
private readonly Dictionary<Publication, TrangaTask> _allTasks; private readonly Dictionary<Publication, Chapter[]> _chapterCollection;
private readonly HashSet<TrangaTask> _allTasks;
private bool _continueRunning = true; private bool _continueRunning = true;
public TaskManager() public TaskManager()
{ {
_allTasks = new Dictionary<Publication, TrangaTask>(); _chapterCollection = new();
_allTasks = new ();
Thread taskChecker = new(TaskCheckerThread); Thread taskChecker = new(TaskCheckerThread);
taskChecker.Start(); taskChecker.Start();
} }
@ -16,7 +18,7 @@ public class TaskManager
{ {
while (_continueRunning) while (_continueRunning)
{ {
foreach (TrangaTask task in _allTasks.Values.Where(tt => (DateTime.Now - tt.lastExecuted) > tt.reoccurrence)) foreach (TrangaTask task in _allTasks.Where(trangaTask => (DateTime.Now - trangaTask.lastExecuted) > trangaTask.reoccurrence))
{ {
if (!task.lastExecutedSuccessfully) if (!task.lastExecutedSuccessfully)
{ {
@ -37,12 +39,12 @@ public class TaskManager
public Publication[] GetAddedPublications() public Publication[] GetAddedPublications()
{ {
return _allTasks.Keys.ToArray(); throw new NotImplementedException();
} }
public TrangaTask[] GetTasks() public TrangaTask[] GetTasks()
{ {
return _allTasks.Values.ToArray(); return _allTasks.ToArray();
} }
public void Shutdown() public void Shutdown()