Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14287 for trunk/sources


Ignore:
Timestamp:
09/17/16 18:59:47 (8 years ago)
Author:
gkronber
Message:

#2667: implemented a workaround objectdisposedexception crashing HL. Hard to debug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r14185 r14287  
    141141
    142142    private void UpdateProgressValue() {
    143       if (InvokeRequired) Invoke((Action)UpdateProgressValue);
    144       else {
     143      // prevent problems with object disposal and invoke as suggested by http://stackoverflow.com/a/18647091
     144      if (!IsHandleCreated) return;
     145      if (InvokeRequired) {
     146        try {
     147          Invoke((Action)UpdateProgressValue);
     148        }
     149        catch (InvalidOperationException) {
     150          if (this.IsHandleCreated) throw;
     151        }
     152      } else {
    145153        if (content != null) {
    146154          double progressValue = content.ProgressValue;
     
    149157          } else {
    150158            progressBar.Style = ProgressBarStyle.Blocks;
    151             progressBar.Value = (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum));
     159            progressBar.Value =
     160              (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum));
    152161          }
    153162        }
Note: See TracChangeset for help on using the changeset viewer.