示例#1
0
        public void Update()
        {
            if (m_taskManagerStarted && m_taskList.Count > 0 || m_newTaskList.Count > 0)
            {
                m_taskList.AddRange(m_newTaskList);
                m_newTaskList.Clear();

                //Update All Tasks
                for (int i = 0; i < m_taskList.Count; i++)
                {
                    BaseTask task = m_taskList[i];
                    if (task.Started)
                    {
                        //This will fire all events for completed or error
                        task.Update();
                        if (task.IsCompleted())
                        {
                            m_removalList.Add(task);
                        }
                    }
                    else
                    {
                        task.Start();
                    }
                }

                //Calculate Progress
                AverageTaskProgress();

                //Remove completed Tasks
                foreach (BaseTask task in m_removalList)
                {
                    m_taskList.Remove(task);
                    task.Dispose();
                }

                m_removalList.Clear();

                //If all tasks are completed
                if (m_taskManagerStarted && m_taskList.Count == 0 && m_newTaskList.Count == 0)
                {
                    if (OnCompleteAllTasks != null)
                    {
                        OnCompleteAllTasks(this);
                    }
                }
            }
        }