Ignore:
Timestamp:
11/29/15 16:59:52 (5 years ago)
Author:
gkronber
Message:

#2071: added progress reporting when importing regression problem data from csv files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionInstanceProviderView.cs

    r12012 r13414  
    2222using System;
    2323using System.IO;
     24using System.Threading.Tasks;
    2425using System.Windows.Forms;
    2526using HeuristicLab.MainForm;
     
    4445      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    4546        IRegressionProblemData instance = null;
    46         try {
    47           instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    48         } catch (IOException ex) {
    49           ErrorWhileParsing(ex);
    50           return;
    51         }
    52         try {
    53           GenericConsumer.Load(instance);
    54           instancesComboBox.SelectedIndex = -1;
    55         } catch (IOException ex) {
    56           ErrorWhileLoading(ex, importTypeDialog.Path);
    57         }
     47
     48        Task.Factory.StartNew(() => {
     49          var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     50          // lock active view and show progress bar
     51          IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     52
     53          try {
     54            var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");
     55
     56            Content.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; };
     57
     58            instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
     59          } catch (IOException ex) {
     60            ErrorWhileParsing(ex);
     61            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     62            return;
     63          }
     64          try {
     65            GenericConsumer.Load(instance);
     66            instancesComboBox.SelectedIndex = -1;
     67          } catch (IOException ex) {
     68            ErrorWhileLoading(ex, importTypeDialog.Path);
     69          } finally {
     70            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     71          }
     72        });
    5873      }
    5974    }
Note: See TracChangeset for help on using the changeset viewer.