Changeset 17276


Ignore:
Timestamp:
09/27/19 10:14:28 (3 weeks ago)
Author:
fholzing
Message:

#2973: Changed cancelation-initiation from VisibleChanged to OnHidden and added a flag, preventing an error in case the View gets closed.

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.Designer.cs

    r17180 r17276  
    192192      this.Name = "ClassificationSolutionVariableImpactsView";
    193193      this.Size = new System.Drawing.Size(712, 365);
    194       this.VisibleChanged += new System.EventHandler(this.ClassificationSolutionVariableImpactsView_VisibleChanged);
    195194      this.ResumeLayout(false);
    196195      this.PerformLayout();
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs

    r17180 r17276  
    4040    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
    4141    private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
     42    private bool attachedToProgress = false;
    4243
    4344    public new IClassificationSolution Content {
     
    8687      }
    8788    }
    88     private void ClassificationSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
     89    protected override void OnHidden(EventArgs e) {
     90      base.OnHidden(e);
    8991      cancellationToken.Cancel();
     92
     93      if (attachedToProgress) {
     94        Progress.Hide(this);
     95        attachedToProgress = false;
     96      }
    9097    }
    9198
     
    126133      variableImpactsArrayView.Caption = Content.Name + " Variable Impacts";
    127134      progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name);
     135      attachedToProgress = true;
    128136      cancellationToken = new CancellationTokenSource();
    129137
     
    144152        UpdateOrdering();
    145153      } finally {
    146         Progress.Hide(this);
     154        if (attachedToProgress) {
     155          Progress.Hide(this);
     156          attachedToProgress = false;
     157        }
    147158      }
    148159    }
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs

    r17180 r17276  
    192192      this.Name = "RegressionSolutionVariableImpactsView";
    193193      this.Size = new System.Drawing.Size(712, 365);
    194       this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged);
    195194      this.ResumeLayout(false);
    196195      this.PerformLayout();
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r17180 r17276  
    4040    private CancellationTokenSource cancellationToken = new CancellationTokenSource();
    4141    private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
     42    private bool attachedToProgress = false;
    4243
    4344    public new IRegressionSolution Content {
     
    8687      }
    8788    }
    88     private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
     89
     90    protected override void OnHidden(EventArgs e) {
     91      base.OnHidden(e);
    8992      cancellationToken.Cancel();
     93
     94      if (attachedToProgress) {
     95        Progress.Hide(this);
     96        attachedToProgress = false;
     97      }
    9098    }
    9199
     
    124132      variableImpactsArrayView.Caption = Content.Name + " Variable Impacts";
    125133      var progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name);
     134      attachedToProgress = true;
    126135      cancellationToken = new CancellationTokenSource();
    127136
     
    141150        rawVariableImpacts.AddRange(impacts);
    142151        UpdateOrdering();
    143       }
    144       finally {
    145         Progress.Hide(this);
     152      } finally {
     153        if (attachedToProgress) {
     154          Progress.Hide(this);
     155          attachedToProgress = false;
     156        }
    146157      }
    147158    }
Note: See TracChangeset for help on using the changeset viewer.