public void addNewTask(Task task) { if (task.taskType == TaskType.INTERRUPTION) interruption++; else if (task.taskType == TaskType.UNPLANNED) unplannedTaskAdded++; switch (task.taskStatus) { case TaskStatus.ABANDONED: abandonedTask++;break; case TaskStatus.COMPLETED: completeTask++;break; case TaskStatus.INQUEUE: inQueueTask++;break; case TaskStatus.SKIPPED: skippedTask++;break; } int index = getTaskAddIndex(task); tasks.Insert(index, task); }
private int getTaskAddIndex(Task task) { for (int i=0;i<tasks.Count;++i) { if (tasks[i].taskStatus != TaskStatus.INQUEUE) { continue; } if ((int)tasks[i].taskPriority>(int)task.taskPriority) { continue; } return i; } return tasks.Count; }