Changeset 9893 for trunk/sources/HeuristicLab.MainForm/3.3/Progress.cs
- Timestamp:
- 08/21/13 23:08:47 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.3/Progress.cs
r9849 r9893 70 70 71 71 public Progress() { 72 progressState = ProgressState.Started; 72 progressState = ProgressState.Finished; 73 canBeCanceled = false; 73 74 } 74 75 public Progress(string status) … … 76 77 this.status = status; 77 78 } 78 public Progress(string status, double progressValue) 79 : this(status) { 80 this.progressValue = progressValue; 79 public Progress(string status, ProgressState state) 80 : this() { 81 this.status = status; 82 this.progressState = state; 81 83 } 82 84 83 public void Cancel(int timeoutMs ) {85 public void Cancel(int timeoutMs = 0) { 84 86 if (canBeCanceled) 85 87 OnCancelRequested(timeoutMs); … … 91 93 } 92 94 95 public void Start() { 96 ProgressValue = 0.0; 97 ProgressState = ProgressState.Started; 98 } 99 100 public void Start(string status) { 101 Start(); 102 Status = status; 103 } 104 93 105 #region Event Handler 94 106 public event EventHandler StatusChanged; 95 107 private void OnStatusChanged() { 96 108 var handler = StatusChanged; 97 try { 98 if (handler != null) handler(this, EventArgs.Empty); 99 } catch { } 109 if (handler != null) handler(this, EventArgs.Empty); 100 110 } 101 111 … … 103 113 private void OnProgressChanged() { 104 114 var handler = ProgressValueChanged; 105 try { 106 if (handler != null) handler(this, EventArgs.Empty); 107 } catch { } 115 if (handler != null) handler(this, EventArgs.Empty); 108 116 } 109 117 … … 111 119 private void OnProgressStateChanged() { 112 120 var handler = ProgressStateChanged; 113 try { 114 if (handler != null) handler(this, EventArgs.Empty); 115 } catch { } 121 if (handler != null) handler(this, EventArgs.Empty); 116 122 } 117 123 … … 119 125 private void OnCanBeCanceledChanged() { 120 126 var handler = CanBeCanceledChanged; 121 try { 122 if (handler != null) handler(this, EventArgs.Empty); 123 } catch { } 127 if (handler != null) handler(this, EventArgs.Empty); 128 124 129 } 125 130 … … 127 132 private void OnCancelRequested(int timeoutMs) { 128 133 var handler = CancelRequested; 129 try { 130 if (handler == null) throw new NotSupportedException("Cancel request was ignored."); 131 else handler(this, new EventArgs<int>(timeoutMs)); 132 } catch { } 134 if (handler != null) throw new NotSupportedException("Cancel request was ignored."); 135 else handler(this, new EventArgs<int>(timeoutMs)); 133 136 } 134 137 #endregion
Note: See TracChangeset
for help on using the changeset viewer.