Esempio 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();
     }
 }
Esempio n. 2
0
 public void AddDependency(ThreadTaskGroup group)
 {
     dependencies.Add(group);
 }
Esempio n. 3
0
 public void AddGroup(ThreadTaskGroup group)
 {
     pendingTaskGroups.Add(group);
 }