private void AddNewTask(Task taskToAdd)
 {
     TaskList.Add(taskToAdd);
     taskToAdd.ActionFinished += delegate { RunNextTask(taskToAdd); };
     if (!ThreadInProgress)
     {
         taskToAdd.DoActionInNewThread();
         ThreadInProgress = true;
     }
 }
 private void RunNextTask(Task taskToAdd)
 {
     TaskList.Remove(taskToAdd);
     if (TaskList.Any())
     {
         TaskList.First().DoActionInNewThread();
     }
     else
     {
         ThreadInProgress = false;
     }
 }
 public static void NotifyAddTask(Task task)
 {
     AddTaskListHandler handler = AddTask;
     if (handler != null) handler(task);
 }