Index: branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Operators/PriorityDispatchingMetaOptEvaluator.cs
===================================================================
--- branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Operators/PriorityDispatchingMetaOptEvaluator.cs	(revision 8808)
+++ branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Operators/PriorityDispatchingMetaOptEvaluator.cs	(revision 8812)
@@ -47,50 +47,56 @@
       double quality = 0;
 
-      ItemList<PickupDeliverySimulation> simulations = SimulationParameter.Value;
+      List<PickupDeliverySimulation> simulations = new List<PickupDeliverySimulation>();
+      foreach (var originalSimulation in SimulationParameter.Value) {
+        PickupDeliverySimulation simulation = originalSimulation.Clone() as PickupDeliverySimulation;
+        PriorityDispatching dispatching = simulation.OptimizationParameter.Value as PriorityDispatching;
+        Parameterize(dispatching);
+
+        simulations.Add(simulation);
+      }
+
       int repetitions = 0;
-
       object locker = new object();
       var options = new ParallelOptions();
       //options.MaxDegreeOfParallelism = Math.Max(Environment.ProcessorCount - 1, 1);
-      Parallel.ForEach<PickupDeliverySimulation>(simulations, options, originalSimulation => {
-        int index = simulations.IndexOf(originalSimulation);
+      Parallel.ForEach<PickupDeliverySimulation>(simulations, options, simulation => {
+        int index = simulations.IndexOf(simulation);
+        int executions = 0;
 
-        PickupDeliverySimulation simulation = originalSimulation.Clone() as PickupDeliverySimulation;
-        PriorityDispatching dispatching = simulation.OptimizationParameter.Value as PriorityDispatching;
-        Parameterize(dispatching);
-       
-        EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
-        EventHandler handler = new EventHandler(delegate(object o, EventArgs e) {
-            waitHandle.Set();                        
+        using (EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset)) {
+          EventHandler handler = new EventHandler(delegate(object o, EventArgs e) {
+            waitHandle.Set();
           });
 
-        int executions = 0;
-        while (executions < RepetitionsParameter.Value.Value) {
-          waitHandle.Reset();
+          while (executions < RepetitionsParameter.Value.Value) {
+            waitHandle.Reset();
 
-          simulation.Prepared += handler;
-          simulation.Prepare(true);
-          waitHandle.WaitOne();
-          simulation.Prepared -= handler;
+            simulation.Prepared += handler;
+            simulation.Prepare(true);
+            waitHandle.WaitOne();
+            simulation.Prepared -= handler;
 
-          waitHandle.Reset();
+            waitHandle.Reset();
 
-          simulation.Stopped += handler;
-          simulation.Start();
-          waitHandle.WaitOne();
-          simulation.Stopped -= handler;
+            simulation.Stopped += handler;
+            simulation.Start();
+            waitHandle.WaitOne();
+            simulation.Stopped -= handler;
 
-          Debug.Assert(simulation.Results.ContainsKey("Finished"));
-          double leadTime = (simulation.Results["LeadTime"].Value as DoubleValue).Value; 
-          double tardiness = (simulation.Results["TardinessPenalty"].Value as DoubleValue).Value;
+            if (!simulation.Results.ContainsKey("Finished")) {
+              throw new Exception("Simulation did not finish");
+            }
+            executions++;
 
-          lock (locker) {
-            double runQuality = leadTime + tardiness;
+            double leadTime = (simulation.Results["LeadTime"].Value as DoubleValue).Value;
+            double tardiness = (simulation.Results["TardinessPenalty"].Value as DoubleValue).Value;
 
-            quality += runQuality;
-            repetitions++;
+            lock (locker) {
+              double runQuality = leadTime + tardiness;
+
+              quality += runQuality;
+              repetitions++;
+            }
           }
-
-          executions++;
         }
       });
