Index: /branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs
===================================================================
--- /branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs	(revision 15215)
+++ /branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs	(revision 15216)
@@ -281,41 +281,46 @@
       }
 
-      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
-        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
-
-      if (Algorithm == null) return;
-      //create cloned algorithms
-      if (clonedAlgorithms.Count == 0) {
-        int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / Folds.Value;
-
-        for (int i = 0; i < Folds.Value; i++) {
-          IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone();
-          clonedAlgorithm.Name = algorithm.Name + " Fold " + i;
-          IDataAnalysisProblem problem = clonedAlgorithm.Problem as IDataAnalysisProblem;
-          ISymbolicDataAnalysisProblem symbolicProblem = problem as ISymbolicDataAnalysisProblem;
-
-          int testStart = (i * testSamplesCount) + SamplesStart.Value;
-          int testEnd = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
-
-          problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
-          problem.ProblemData.TrainingPartition.End = SamplesEnd.Value;
-          problem.ProblemData.TestPartition.Start = testStart;
-          problem.ProblemData.TestPartition.End = testEnd;
-          DataAnalysisProblemData problemData = problem.ProblemData as DataAnalysisProblemData;
-          if (problemData != null) {
-            problemData.TrainingPartitionParameter.Hidden = false;
-            problemData.TestPartitionParameter.Hidden = false;
+      try {
+        if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
+          throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
+
+        if (Algorithm == null) return;
+        //create cloned algorithms
+        if (clonedAlgorithms.Count == 0) {
+          int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / Folds.Value;
+
+          for (int i = 0; i < Folds.Value; i++) {
+            IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone();
+            clonedAlgorithm.Name = algorithm.Name + " Fold " + i;
+            IDataAnalysisProblem problem = clonedAlgorithm.Problem as IDataAnalysisProblem;
+            ISymbolicDataAnalysisProblem symbolicProblem = problem as ISymbolicDataAnalysisProblem;
+
+            int testStart = (i * testSamplesCount) + SamplesStart.Value;
+            int testEnd = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
+
+            problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
+            problem.ProblemData.TrainingPartition.End = SamplesEnd.Value;
+            problem.ProblemData.TestPartition.Start = testStart;
+            problem.ProblemData.TestPartition.End = testEnd;
+            DataAnalysisProblemData problemData = problem.ProblemData as DataAnalysisProblemData;
+            if (problemData != null) {
+              problemData.TrainingPartitionParameter.Hidden = false;
+              problemData.TestPartitionParameter.Hidden = false;
+            }
+
+            if (symbolicProblem != null) {
+              symbolicProblem.FitnessCalculationPartition.Start = SamplesStart.Value;
+              symbolicProblem.FitnessCalculationPartition.End = SamplesEnd.Value;
+            }
+            clonedAlgorithm.Prepare();
+            clonedAlgorithms.Add(clonedAlgorithm);
           }
-
-          if (symbolicProblem != null) {
-            symbolicProblem.FitnessCalculationPartition.Start = SamplesStart.Value;
-            symbolicProblem.FitnessCalculationPartition.End = SamplesEnd.Value;
-          }
-          clonedAlgorithm.Prepare();
-          clonedAlgorithms.Add(clonedAlgorithm);
-        }
-      }
-
-      OnStarted();
+        }
+
+        OnStarted();
+      } finally {
+        if (startPending) startPending = false;
+      }
+
       availableWorkers = new SemaphoreSlim(NumberOfWorkers.Value, NumberOfWorkers.Value);
       allAlgorithmsFinished = new ManualResetEventSlim(false);
