/** * Performs the current task in the queue and checks to see if the task is complete. If the task * is complete, this removes the task from the queue and performs any necessary clean-up. */ public void DoCurrentTask() { try { // If we have something to do, try to get it done if (currentTask != null) { currentTask.PerformTaskActions(); // Check to see if the current task is complete if (currentTask.IsComplete()) { // Perform any cleanup actions associated with the task with // which we're finished currentTask.CleanUpTask(); // If we have another task to do, make it the current task, // otherwise we make the current task null if (taskQueue.Size() > 0) { currentTask = taskQueue.Pop(); } else { currentTask = null; } } } else if (taskQueue.Size() > 0) { currentTask = taskQueue.Pop(); } } catch (Exception ex) { currentTask = null; System.err.println(ex.toString()); } }
/** Removes all tasks from the queue, performing clean-up actions as necessary. */ public void ClearAllTasks() { TaskBase popedTask; while (taskQueue.Size() > 0) { // Remove the task from the queue and perform necessary clean-up // actions try { popedTask = taskQueue.Pop(); popedTask.CleanUpTask(); } catch (Exception ex) { System.err.println(ex.toString()); } } // In addition to clearing the queue, set the current task to null currentTask = null; }