Esempio n. 1
0
  /**
   * 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());
    }
  }
Esempio n. 2
0
  /**
   * Returns true if a current task exists.
   *
   * @return True if a current task exists, false otherwise
   */
  public boolean PerformingTask() {
    // If we are doing a task or are about to do a task,
    // return true
    if (taskQueue.Size() > 0 || currentTask != null) {
      return true;
    }

    return false;
  }
Esempio n. 3
0
  /** 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;
  }