Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14881


Ignore:
Timestamp:
04/21/17 07:12:31 (7 years ago)
Author:
gkronber
Message:

#2667: merged r14287 and r14297 from trunk to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r14186 r14881  
    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.