Index: branches/GP-MoveOperators/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
===================================================================
--- branches/GP-MoveOperators/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs	(revision 8085)
+++ branches/GP-MoveOperators/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs	(revision 8206)
@@ -35,12 +35,9 @@
 namespace HeuristicLab.Clients.OKB.RunCreation {
   [View("OKBExperimentUpload View")]
-  [Content(typeof(RunCollection), false)]
   [Content(typeof(IOptimizer), false)]
   public partial class OKBExperimentUploadView : ItemView {
     public new IOptimizer Content {
       get { return (IOptimizer)base.Content; }
-      set {
-        base.Content = value;
-      }
+      set { base.Content = value; }
     }
 
@@ -58,7 +55,12 @@
     Problem selectedProblem = null;
     private ProgressView progressView;
+    private Progress progress;
 
     public OKBExperimentUploadView() {
       InitializeComponent();
+      progress = new Progress() {
+        CanBeCanceled = false,
+        ProgressState = ProgressState.Finished
+      };
     }
 
@@ -94,4 +96,5 @@
       RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing);
       RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed);
+      progressView = new ProgressView(this, progress);
     }
 
@@ -99,4 +102,9 @@
       RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing);
       RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
+      if (progressView != null) {
+        progressView.Content = null;
+        progressView.Dispose();
+        progressView = null;
+      }
       base.DeregisterContentEvents();
     }
@@ -108,5 +116,10 @@
     private void DisplayRuns(RunCollection runs) {
       if (RunCreationClient.Instance.Algorithms == null || RunCreationClient.Instance.Algorithms.Count() == 0) {
-        RunCreationClient.Instance.RefreshAsync(DisplayError);
+        Action a = new Action(delegate {
+          RunCreationClient.Instance.Refresh();
+          CreateUI(runs);
+        });
+
+        Task.Factory.StartNew(a).ContinueWith((t) => { DisplayError(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted);
       } else {
         CreateUI(runs);
@@ -115,52 +128,56 @@
 
     private void CreateUI(RunCollection runs) {
-      if (problems.Count == 0)
-        problems.AddRange(RunCreationClient.Instance.Problems);
-      if (algorithms.Count == 0)
-        algorithms.AddRange(RunCreationClient.Instance.Algorithms);
-
-      IItem algorithmType;
-      IItem problemType;
-      IItem algorithmName;
-      IItem problemName;
-
-      DataGridViewComboBoxColumn cmbAlgorithm = dataGridView.Columns[algorithmColumnIndex] as DataGridViewComboBoxColumn;
-      cmbAlgorithm.DataSource = algorithms;
-      cmbAlgorithm.DisplayMember = "Name";
-
-      DataGridViewComboBoxColumn cmbProblem = dataGridView.Columns[problemColumnIndex] as DataGridViewComboBoxColumn;
-      cmbProblem.DataSource = problems;
-      cmbProblem.DisplayMember = "Name";
-
-      foreach (IRun run in runs) {
-        int idx = dataGridView.Rows.Add(run.Name);
-        DataGridViewRow curRow = dataGridView.Rows[idx];
-        curRow.Tag = run;
-
-        if (run.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) {
-          HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue;
-          if (algStr != null) {
-            curRow.Cells[1].Value = algStr;
-          }
-        }
-
-        if (run.Parameters.TryGetValue(algorithmNameParameterName, out algorithmName)) {
-          HeuristicLab.Data.StringValue algStr = algorithmName as HeuristicLab.Data.StringValue;
-          if (algStr != null) {
-            curRow.Cells[2].Value = algStr;
-          }
-        }
-
-        if (run.Parameters.TryGetValue(problemTypeParameterName, out problemType)) {
-          HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue;
-          if (prbStr != null) {
-            curRow.Cells[4].Value = prbStr;
-          }
-        }
-
-        if (run.Parameters.TryGetValue(problemNameParameterName, out problemName)) {
-          HeuristicLab.Data.StringValue prbStr = problemName as HeuristicLab.Data.StringValue;
-          if (prbStr != null) {
-            curRow.Cells[5].Value = prbStr;
+      if (InvokeRequired) {
+        Invoke(new Action<RunCollection>(CreateUI), runs);
+      } else {
+        if (problems.Count == 0)
+          problems.AddRange(RunCreationClient.Instance.Problems);
+        if (algorithms.Count == 0)
+          algorithms.AddRange(RunCreationClient.Instance.Algorithms);
+
+        IItem algorithmType;
+        IItem problemType;
+        IItem algorithmName;
+        IItem problemName;
+
+        DataGridViewComboBoxColumn cmbAlgorithm = dataGridView.Columns[algorithmColumnIndex] as DataGridViewComboBoxColumn;
+        cmbAlgorithm.DataSource = algorithms;
+        cmbAlgorithm.DisplayMember = "Name";
+
+        DataGridViewComboBoxColumn cmbProblem = dataGridView.Columns[problemColumnIndex] as DataGridViewComboBoxColumn;
+        cmbProblem.DataSource = problems;
+        cmbProblem.DisplayMember = "Name";
+
+        foreach (IRun run in runs) {
+          int idx = dataGridView.Rows.Add(run.Name);
+          DataGridViewRow curRow = dataGridView.Rows[idx];
+          curRow.Tag = run;
+
+          if (run.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) {
+            HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue;
+            if (algStr != null) {
+              curRow.Cells[1].Value = algStr;
+            }
+          }
+
+          if (run.Parameters.TryGetValue(algorithmNameParameterName, out algorithmName)) {
+            HeuristicLab.Data.StringValue algStr = algorithmName as HeuristicLab.Data.StringValue;
+            if (algStr != null) {
+              curRow.Cells[2].Value = algStr;
+            }
+          }
+
+          if (run.Parameters.TryGetValue(problemTypeParameterName, out problemType)) {
+            HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue;
+            if (prbStr != null) {
+              curRow.Cells[4].Value = prbStr;
+            }
+          }
+
+          if (run.Parameters.TryGetValue(problemNameParameterName, out problemName)) {
+            HeuristicLab.Data.StringValue prbStr = problemName as HeuristicLab.Data.StringValue;
+            if (prbStr != null) {
+              curRow.Cells[5].Value = prbStr;
+            }
           }
         }
@@ -169,6 +186,10 @@
 
     private void ClearRuns() {
-      dataGridView.Rows.Clear();
-      runs.Clear();
+      if (InvokeRequired) {
+        Invoke(new Action(ClearRuns));
+      } else {
+        dataGridView.Rows.Clear();
+        runs.Clear();
+      }
     }
 
@@ -177,7 +198,6 @@
         Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e);
       } else {
-        IProgress prog = new Progress();
-        prog.Status = "Refreshing algorithms and problems...";
-        SetProgressView(prog);
+        progress.Status = "Refreshing algorithms and problems...";
+        progress.ProgressState = ProgressState.Started;
       }
     }
@@ -187,5 +207,5 @@
         Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e);
       } else {
-        FinishProgressView();
+        progress.Finish();
         SetEnabledStateOfControls();
       }
@@ -195,5 +215,5 @@
       var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync);
       task.ContinueWith((t) => {
-        FinishProgressView();
+        progress.Finish();
         PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception);
       }, TaskContinuationOptions.OnlyOnFaulted);
@@ -201,11 +221,9 @@
 
     private void UploadAsync() {
-      IProgress prog = new Progress();
-      prog.Status = "Uploading runs to OKB...";
-      prog.ProgressValue = 0;
+      progress.Status = "Uploading runs to OKB...";
+      progress.ProgressValue = 0;
+      progress.ProgressState = ProgressState.Started;
       double count = dataGridView.Rows.Count;
       int i = 0;
-
-      SetProgressView(prog);
       foreach (DataGridViewRow row in dataGridView.Rows) {
         selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault();
@@ -218,32 +236,8 @@
         run.Store();
         i++;
-        prog.ProgressValue = ((double)i) / count;
-      }
-      FinishProgressView();
-    }
-
-    private void SetProgressView(IProgress progress) {
-      if (InvokeRequired) {
-        Invoke(new Action<IProgress>(SetProgressView), progress);
-      } else {
-        if (progressView == null) {
-          progressView = new ProgressView(this, progress);
-        } else {
-          progressView.Progress = progress;
-        }
-      }
-    }
-
-    private void FinishProgressView() {
-      if (InvokeRequired) {
-        Invoke(new Action(FinishProgressView));
-      } else {
-        if (progressView != null) {
-          progressView.Finish();
-          progressView = null;
-          SetEnabledStateOfControls();
-          ClearRuns();
-        }
-      }
+        progress.ProgressValue = ((double)i) / count;
+      }
+      progress.Finish();
+      ClearRuns();
     }
 
