private void getResults(TimePointResult timePointResult, IList <Future <IList <RobotResult> > > tasks)
 {
     while (tasks.Count > 0)
     {
         try
         {
             int lastIndex = tasks.Count - 1;
             Future <IList <RobotResult> > future  = tasks[lastIndex];
             IList <RobotResult>           results = future.get();
             tasks.RemoveAt(lastIndex);
             results.ForEach(timePointResult.addRobotResult);
         }
         catch (InterruptedException)
         {
             /* Do nothing, try again */
         }
         catch (ExecutionException e)
         {
             output.errorMessage(e.Message);
             Console.WriteLine(e.ToString());
             Console.Write(e.StackTrace);
             Environment.Exit(1);
         }
     }
 }
        public virtual TimePointResult execute(IList <RobotData> robotDataList, Population population, bool updateRobots)
        {
            robotInfos.Clear();
            TimePointResult timePointResult = new TimePointResult();

            if (robotDataList.Count == 0)
            {
                return(timePointResult);
            }
            IList <Future <IList <RobotResult> > > tasks = submitTasks(robotDataList, population, updateRobots);

            getResults(timePointResult, tasks);
            return(timePointResult);
        }