public CacheManager() { // Make sure a Cache directory exists if (!Directory.Exists("Cache")) { Directory.CreateDirectory("Cache"); } InstrumentCaches = new List <InstrumentCache>(); Tasks = new LinkedList <CacheTask>(); TaskAtHand = null; }
/// <summary> /// Starts running the next task in the list /// </summary> public void StartNextTask() { lock (TasksLock) { if (TaskAtHand != null) { Tasks.Remove(TaskAtHand); } if (Tasks.Count > 0) { TaskAtHand = Tasks.First.Value; } else { TaskAtHand = null; } } TaskAtHand?.Start(); }
public void AddNonurgentTask(CacheTask cacheTask) { Tasks.AddLast(cacheTask); }
/// <summary> /// Adds a task that is needed urgently. /// </summary> /// <param name="cacheTask"></param> public void AddUrgentTask(CacheTask cacheTask) { Tasks.AddFirst(cacheTask); }