Index: trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
===================================================================
--- trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs	(revision 15793)
+++ trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs	(revision 15796)
@@ -22,7 +22,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
 using HeuristicLab.Common;
 using HeuristicLab.Data;
@@ -33,5 +32,10 @@
   [Content(typeof(IRegressionSolution))]
   public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView {
-    #region Nested Types
+    private class BackgroundworkerArguments {
+      internal MainForm.WindowsForms.MainForm mainForm;
+      internal RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum replMethod;
+      internal RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum factorReplMethod;
+      internal RegressionSolutionVariableImpactsCalculator.DataPartitionEnum dataPartition;
+    }
     private enum SortingCriteria {
       ImpactValue,
@@ -39,12 +43,8 @@
       VariableName
     }
-    #endregion
-
-    #region Fields
+    private IProgress progress;
     private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>();
-    private Thread thread;
-    #endregion
-
-    #region Getter/Setter
+    private BackgroundWorker worker = new BackgroundWorker();
+
     public new IRegressionSolution Content {
       get { return (IRegressionSolution)base.Content; }
@@ -53,7 +53,5 @@
       }
     }
-    #endregion
-
-    #region Ctor
+
     public RegressionSolutionVariableImpactsView()
       : base() {
@@ -68,8 +66,42 @@
       this.replacementComboBox.SelectedIndex = 0;
       this.factorVarReplComboBox.SelectedIndex = 0;
-    }
-    #endregion
-
-    #region Events
+
+      //Worker magic
+      worker.WorkerSupportsCancellation = true;
+      worker.WorkerReportsProgress = true;
+      worker.DoWork += Worker_DoWork;
+      worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
+      worker.ProgressChanged += Worker_ProgressChanged;
+    }
+
+
+    private void Worker_DoWork(object sender, DoWorkEventArgs e) {
+      var args = e.Argument as BackgroundworkerArguments;
+
+      //Remember the original ordering of the variables
+      var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, args.dataPartition, args.replMethod, args.factorReplMethod,
+        (i) => {
+          var worker = (sender as BackgroundWorker);
+          worker.ReportProgress(0, i);
+          return worker.CancellationPending;
+        });
+
+      if ((sender as BackgroundWorker).CancellationPending) { return; }
+      var problemData = Content.ProblemData;
+      var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction));
+      var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList();
+
+      rawVariableImpacts.Clear();
+      originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2));
+    }
+    private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
+      progress.ProgressValue = (double)e.UserState;
+    }
+    private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
+      if (e.Error != null) { throw e.Error; }
+      if (e.Error == null && !e.Cancelled) { UpdateDataOrdering(); }
+      ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this);
+    }
+
     protected override void RegisterContentEvents() {
       base.RegisterContentEvents();
@@ -102,8 +134,6 @@
 
     private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
-      if (thread == null) { return; }
-
-      if (thread.IsAlive) { thread.Abort(); }
-      thread = null;
+      if (!worker.IsBusy) { return; }
+      worker.CancelAsync();
     }
 
@@ -142,7 +172,5 @@
     }
 
-    #endregion
-
-    #region Helper Methods   
+
     private void UpdateVariableImpact() {
       //Check if the selection is valid
@@ -159,22 +187,15 @@
 
       variableImactsArrayView.Caption = Content.Name + " Variable Impacts";
-
-      mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name);
-
-      Task.Factory.StartNew(() => {
-        thread = Thread.CurrentThread;
-        //Remember the original ordering of the variables
-        var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod);
-        var problemData = Content.ProblemData;
-        var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(Content.Model.VariablesUsedForPrediction));
-        var originalVariableOrdering = problemData.Dataset.VariableNames.Where(v => inputvariables.Contains(v)).Where(problemData.Dataset.VariableHasType<double>).ToList();
-
-        rawVariableImpacts.Clear();
-        originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2));
-      }).ContinueWith((o) => {
-        UpdateDataOrdering();
-        mainForm.RemoveOperationProgressFromView(this);
-        thread = null;
-      }, TaskScheduler.FromCurrentSynchronizationContext());
+      progress = mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name);
+      progress.ProgressValue = 0;
+
+      if (!worker.IsBusy) {
+        worker.RunWorkerAsync(new BackgroundworkerArguments() {
+          mainForm = mainForm,
+          dataPartition = dataPartition,
+          factorReplMethod = factorReplMethod,
+          replMethod = replMethod
+        });
+      }
     }
 
@@ -221,5 +242,4 @@
       }
     }
-    #endregion
   }
 }
Index: trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs
===================================================================
--- trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs	(revision 15793)
+++ trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs	(revision 15796)
@@ -52,5 +52,5 @@
       All
     }
-   
+
     private const string ReplacementParameterName = "Replacement Method";
     private const string DataPartitionParameterName = "DataPartition";
@@ -96,5 +96,5 @@
       DataPartitionEnum data = DataPartitionEnum.Training,
       ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Median,
-      FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) {
+      FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best, Func<double, bool> progressCallback = null) {
 
       var problemData = solution.ProblemData;
@@ -134,6 +134,12 @@
       var allowedInputVariables = dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList();
 
+      int curIdx = 1;
+      int count = allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>).Count();
       // calculate impacts for double variables
       foreach (var inputVariable in allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>)) {
+        //Report the current progress in percent. If the callback returns true, it means the execution shall be stopped
+        if (progressCallback != null) {
+          if (progressCallback((double)curIdx++ / count)) { return null; }
+        }
         var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, replacementMethod);
         var newR2 = OnlinePearsonsRCalculator.Calculate(targetValues, newEstimates, out error);
@@ -180,4 +186,5 @@
     }
 
+
     private static IEnumerable<double> EvaluateModelWithReplacedVariable(IRegressionModel model, string variable, ModifiableDataset dataset, IEnumerable<int> rows, ReplacementMethodEnum replacement = ReplacementMethodEnum.Median) {
       var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList();
