Esempio n. 1
0
 public void SetTaskManager(TaskManager taskManager)
 {
     this.taskManager = taskManager;
     taskManager.Started += new EventHandler(taskManager_Started);
     taskManager.StatusUpdated += new StatusUpdateEventHandler(taskManager_StatusUpdated);
     taskManager.Finished += new EventHandler(taskManager_Finished);
 }
Esempio n. 2
0
 private TaskManager(TaskManager parent, string name, double taskSize)
 {
     this.parent = parent;
     Name = name;
     TaskSize = taskSize;
 }
Esempio n. 3
0
 public void Dispose()
 {
     if (parent == null)
     {
         throw new Exception("Cannot dispose the root task");
     }
     parent.receivedSize += TaskSize;
     parent.child = null;
     current = parent;
     if (Finished != null)
     {
         Finished(this, new EventArgs());
     }
 }
Esempio n. 4
0
        public static TaskManager Start(string taskName, bool unpredictable)
        {
            TaskManager newTaskManager;

            if (!current.expecting.TryGetValue(taskName, out newTaskManager))
            {
                throw new Exception("Not expecting task " + taskName);
            }
            current.expecting.Remove(taskName);

            newTaskManager.unpredictable = unpredictable;

            newTaskManager.StatusUpdated += current.ChildStatusUpdated;
            newTaskManager.Started += current.ChildStarted;
            newTaskManager.Finished += current.ChildFinished;

            current.child = newTaskManager;
            current = newTaskManager;

            newTaskManager.Started(newTaskManager, new EventArgs());

            return newTaskManager;
        }