Index: branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
===================================================================
--- branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs	(revision 5231)
+++ branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs	(revision 5262)
@@ -50,5 +50,7 @@
       //TestCombinations4();
       //TestAlgorithmPerformanceIssue();
-      TestWaitAny();
+      //TestWaitAny();
+      TestExecutionTimeUpdateInvervalPerformance();
+      return;
 
       GeneticAlgorithm baseLevelAlgorithm = new GeneticAlgorithm();
@@ -78,4 +80,111 @@
 
       Console.ReadLine();
+    }
+
+    private static void TestExecutionTimeUpdateInvervalPerformance() {
+      TableBuilder tb = new TableBuilder("Tasks", "Interval", "TotalExecutionTime", "AvgExecutionTime", "TimeElapsed", "TotalTimeElapsed", "Speedup", "ExecutionTimeChangedCount", "RealExecutionTimeUpdate(ms)");
+      int tasks = 32;
+      int repetitions = 3;
+
+      // warmup
+      RepeatExecuteParallel(3, 1, 1, tb);
+      tb.AppendRow("--", "--", "--", "--", "--", "--", "--", "--", "--");
+      RepeatExecuteParallel(repetitions, tasks, 1, tb); 
+      RepeatExecuteParallel(repetitions, tasks, 2.5, tb); 
+      RepeatExecuteParallel(repetitions, tasks, 5, tb);
+      RepeatExecuteParallel(repetitions, tasks, 10, tb);
+      RepeatExecuteParallel(repetitions, tasks, 25, tb);
+      RepeatExecuteParallel(repetitions, tasks, 50, tb);
+      RepeatExecuteParallel(repetitions, tasks, 100, tb); 
+      RepeatExecuteParallel(repetitions, tasks, 250, tb); 
+      RepeatExecuteParallel(repetitions, tasks, 500, tb); 
+      RepeatExecuteParallel(repetitions, tasks, 1000, tb);
+      RepeatExecuteParallel(repetitions, tasks, 2500, tb);     
+      RepeatExecuteParallel(repetitions, tasks, 5000, tb);
+
+      using (var sw = new StreamWriter("TestExecutionTimeUpdateInvervalPerformance.txt")) {
+        sw.Write(tb.ToString());
+      }
+    }
+
+    private static GeneticAlgorithm CreateGA() {
+      GeneticAlgorithm ga = new GeneticAlgorithm();
+      ga.Problem = new SingleObjectiveTestFunctionProblem() { ProblemSize = new IntValue(250) };
+      ga.Engine = new SequentialEngine.SequentialEngine();
+      ga.SetSeedRandomly.Value = false;
+      ga.Seed.Value = 0;
+      return ga;
+    }
+
+    private static void RepeatExecuteParallel(int repetitions, int tasks, double executionTimeUpdateIntervalMs, TableBuilder tb) {
+      for (int i = 0; i < repetitions; i++) {
+        ExecuteParallel(tasks, executionTimeUpdateIntervalMs, tb); 
+        Console.Clear(); 
+        Console.WriteLine(tb.ToString());
+      }
+    }
+
+    private static void ExecuteParallel(int taskCount, double executionTimeUpdateIntervalMs, TableBuilder tb) {
+      Task<TimeSpan>[] tasks = new Task<TimeSpan>[taskCount];
+      EngineAlgorithm[] algs = new EngineAlgorithm[taskCount];
+      for (int i = 0; i < taskCount; i++) {
+        GeneticAlgorithm alg = CreateGA();
+        ((Engine)alg.Engine).ExecutionTimeUpdateInterval = TimeSpan.FromMilliseconds(executionTimeUpdateIntervalMs);
+        algs[i] = alg;
+      }
+      Console.WriteLine("Creating algs finished.");
+
+      for (int i = 0; i < taskCount; i++) {
+        tasks[i] = new Task<TimeSpan>((alg) => {
+          Console.WriteLine("Task {0} started.", Task.CurrentId);
+          
+          Stopwatch swx = new Stopwatch();
+          swx.Start();
+          ((EngineAlgorithm)alg).ExecutionTimeChanged += new EventHandler(Program_ExecutionTimeChanged);
+          var executor = new AlgorithmExecutor((EngineAlgorithm)alg);
+          executor.StartSync();
+          ((EngineAlgorithm)alg).ExecutionTimeChanged -= new EventHandler(Program_ExecutionTimeChanged);
+          swx.Stop();
+          Console.WriteLine("Task {0} finished.", Task.CurrentId);
+          return swx.Elapsed;
+        }, algs[i]);
+      }
+      Console.WriteLine("Creating tasks finished.");
+      counter = 0;
+      Stopwatch sw = new Stopwatch();
+      sw.Start();
+      foreach (var task in tasks) task.Start();
+      Task.WaitAll(tasks);
+      sw.Stop();
+
+      if (!algs.All(alg => alg.ExecutionState == ExecutionState.Stopped))
+        throw new Exception("Not all algs stopped properly");
+
+      if (!algs.All(alg => ((DoubleValue)alg.Results["BestQuality"].Value).Value == ((DoubleValue)algs.First().Results["BestQuality"].Value).Value))
+        throw new Exception("Not all algs have the same resutls");
+
+      if (tb != null) {
+        double totalExecutionTimeMilliseconds = algs.Select(x => x.ExecutionTime.TotalMilliseconds).Sum();
+        double totalMilliseconds = tasks.Select(t => t.Result.TotalMilliseconds).Sum();
+        tb.AppendRow(
+          taskCount.ToString(), 
+          executionTimeUpdateIntervalMs.ToString(), 
+          TimeSpan.FromMilliseconds(totalExecutionTimeMilliseconds).ToString(),
+          TimeSpan.FromMilliseconds(totalExecutionTimeMilliseconds / taskCount).ToString(), 
+          sw.Elapsed.ToString(),
+          TimeSpan.FromMilliseconds(totalMilliseconds).ToString(),
+          (totalMilliseconds / sw.ElapsedMilliseconds).ToString("0.00"),
+          counter.ToString(),
+          (totalExecutionTimeMilliseconds/counter).ToString("0.00"));
+      }
+      tasks = null;
+      algs = null;
+      GC.Collect();
+      Console.WriteLine("Test finished.");
+    }
+
+    private static int counter = 0;
+    static void Program_ExecutionTimeChanged(object sender, EventArgs e) {
+      System.Threading.Interlocked.Increment(ref counter);
     }
 
