//a method that cancels an in progress task public void CancelInProgressTask(int queueIndex) { if (queueIndex < 0 || queueIndex >= tasksQueue.Count) //invalid task index { return; } int taskID = tasksQueue[queueIndex]; //get the actual task ID tasksQueue.RemoveAt(queueIndex); //remove from queue tasksList[taskID].Cancel(); //cancel the task CustomEvents.OnTaskCanceled(this, taskID, queueIndex); if (queueIndex == 0) //if the first task in the queue was the one that got cancelled and we still have more in queue { StartNextTask(); } }
//a method that cancels an in progress task public void CancelInProgressTask(int queueIndex) { if (queueIndex < 0 || queueIndex >= tasksQueue.Count) //invalid task index { return; } int taskID = tasksQueue[queueIndex]; //get the actual task ID tasksQueue.RemoveAt(queueIndex); //remove from queue tasksList[taskID].Cancel(); //cancel the task CustomEvents.OnTaskCanceled(this, taskID, queueIndex); if (queueIndex == 0 && tasksQueue.Count > 0) //if the first task in the queue was the one that got cancelled and we still have more in queue { //If it's the first task in the queue, reload the timer for the next task: taskQueueTimer = tasksList[taskID].GetReloadTime(); } }