Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8012 for trunk/sources


Ignore:
Timestamp:
06/15/12 21:37:27 (12 years ago)
Author:
abeham
Message:

#1851: fixed cancellation of experiment creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r8011 r8012  
    682682      int counter = 0, totalVariations = GetNumberOfVariations();
    683683      if (instances.Count == 0) {
    684         AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
     684        try {
     685          AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
     686        } catch (OperationCanceledException) {
     687          e.Cancel = true;
     688          localExperiment = null;
     689          return;
     690        }
    685691        experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
    686 
    687692      } else {
    688693        foreach (var provider in instances.Keys) {
    689694          foreach (var descriptor in instances[provider]) {
    690             #region Check cancellation request
    691             if (experimentCreationBackgroundWorker.CancellationPending) {
    692               e.Cancel = true;
    693               localExperiment = null;
    694               return;
    695             }
    696             #endregion
    697695            var algorithm = (IAlgorithm)Optimizer.Clone();
    698696            bool failed = false;
    699697            try {
    700698              ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
    701             }
    702             catch (Exception ex) {
     699            } catch (Exception ex) {
    703700              failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
    704701              failed = true;
    705702            }
    706703            if (!failed) {
    707 
    708               AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     704              try {
     705                AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     706              } catch (OperationCanceledException) {
     707                e.Cancel = true;
     708                localExperiment = null;
     709                return;
     710              }
    709711            } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
    710712          }
     
    724726      var variations = experimentCreationBackgroundWorker_CalculateParameterVariations(optimizer);
    725727      foreach (var v in variations) {
     728        if (experimentCreationBackgroundWorker.CancellationPending)
     729          throw new OperationCanceledException();
    726730        AddOptimizer(v, localExperiment);
    727731        counter++;
Note: See TracChangeset for help on using the changeset viewer.