Ejemplo n.º 1
0
 public void RunTasks(float time)
 {
     currentTime = time;
     while (pendingTaskGroups.Count > 0 || runningTaskGroups.Count > 0)
     {
         for (int groupIndex = pendingTaskGroups.Count - 1; groupIndex >= 0; --groupIndex)
         {
             if (pendingTaskGroups[groupIndex].CanBeQueued())
             {
                 ThreadTaskGroup taskGroup = pendingTaskGroups[groupIndex];
                 runningTaskGroups.Add(taskGroup);
                 pendingTaskGroups.RemoveAt(groupIndex);
                 foreach (ThreadTask task in taskGroup.Tasks)
                 {
                     ThreadPool.QueueUserWorkItem(task.Callback, time);
                 }
                 Thread.Yield();
             }
         }
         for (int runningGroupIndex = runningTaskGroups.Count - 1; runningGroupIndex >= 0; --runningGroupIndex)
         {
             if (runningTaskGroups[runningGroupIndex].IsDone())
             {
                 completedTaskGroups.Add(runningTaskGroups[runningGroupIndex]);
                 runningTaskGroups.RemoveAt(runningGroupIndex);
             }
         }
         Thread.Yield();
     }
 }
Ejemplo n.º 2
0
 public void AddDependency(ThreadTaskGroup group)
 {
     dependencies.Add(group);
 }
Ejemplo n.º 3
0
 public void AddGroup(ThreadTaskGroup group)
 {
     pendingTaskGroups.Add(group);
 }