Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/13/16 19:47:41 (8 years ago)
Author:
gkronber
Message:

#2650 Merged r14282:14322 from trunk to branch (fixing conflicts)

Location:
branches/symbreg-factors-2650
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650

  • branches/symbreg-factors-2650/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r14185 r14330  
    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          // swallow ObjectDisposedException
     151          // which might occur if the invoke call is executed after or while the control is disposing
     152        }
     153      } else {
    145154        if (content != null) {
    146155          double progressValue = content.ProgressValue;
     
    149158          } else {
    150159            progressBar.Style = ProgressBarStyle.Blocks;
    151             progressBar.Value = (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum));
     160            progressBar.Value =
     161              (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum));
    152162          }
    153163        }
Note: See TracChangeset for help on using the changeset viewer.