Changeset 9933 for stable/HeuristicLab.MainForm/3.3/Progress.cs
- Timestamp:
- 09/03/13 15:55:36 (11 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 9849,9851,9865,9867-9868,9893-9896,9900-9901,9905,9907
- Property svn:mergeinfo changed
-
stable/HeuristicLab.MainForm/3.3/Progress.cs
r9456 r9933 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 25 24 namespace HeuristicLab.MainForm { … … 50 49 public ProgressState ProgressState { 51 50 get { return progressState; } 52 set {51 private set { 53 52 if (progressState != value) { 54 53 progressState = value; … … 70 69 71 70 public Progress() { 72 progressState = ProgressState.Started; 71 progressState = ProgressState.Finished; 72 canBeCanceled = false; 73 73 } 74 74 public Progress(string status) … … 76 76 this.status = status; 77 77 } 78 public Progress(string status, double progressValue) 79 : this(status) { 80 this.progressValue = progressValue; 78 public Progress(string status, ProgressState state) 79 : this() { 80 this.status = status; 81 this.progressState = state; 81 82 } 82 83 83 public void Cancel( int timeoutMs) {84 public void Cancel() { 84 85 if (canBeCanceled) 85 OnCancelRequested( timeoutMs);86 OnCancelRequested(); 86 87 } 87 88 88 /// <summary>89 /// Sets the ProgressValue to 1 and the ProgressState to Finished.90 /// </summary>91 89 public void Finish() { 92 90 if (ProgressValue != 1.0) ProgressValue = 1.0; 93 91 ProgressState = ProgressState.Finished; 92 } 93 94 public void Start() { 95 ProgressValue = 0.0; 96 ProgressState = ProgressState.Started; 97 } 98 99 public void Start(string status) { 100 Start(); 101 Status = status; 94 102 } 95 103 … … 98 106 private void OnStatusChanged() { 99 107 var handler = StatusChanged; 100 try { 101 if (handler != null) handler(this, EventArgs.Empty); 102 } catch { } 108 if (handler != null) handler(this, EventArgs.Empty); 103 109 } 104 110 … … 106 112 private void OnProgressChanged() { 107 113 var handler = ProgressValueChanged; 108 try { 109 if (handler != null) handler(this, EventArgs.Empty); 110 } catch { } 114 if (handler != null) handler(this, EventArgs.Empty); 111 115 } 112 116 … … 114 118 private void OnProgressStateChanged() { 115 119 var handler = ProgressStateChanged; 116 try { 117 if (handler != null) handler(this, EventArgs.Empty); 118 } catch { } 120 if (handler != null) handler(this, EventArgs.Empty); 119 121 } 120 122 … … 122 124 private void OnCanBeCanceledChanged() { 123 125 var handler = CanBeCanceledChanged; 124 try { 125 if (handler != null) handler(this, EventArgs.Empty); 126 } catch { } 126 if (handler != null) handler(this, EventArgs.Empty); 127 127 } 128 128 129 public event EventHandler <EventArgs<int>>CancelRequested;130 private void OnCancelRequested( int timeoutMs) {129 public event EventHandler CancelRequested; 130 private void OnCancelRequested() { 131 131 var handler = CancelRequested; 132 try { 133 if (handler == null) throw new NotSupportedException("Cancel request was ignored."); 134 else handler(this, new EventArgs<int>(timeoutMs)); 135 } catch { } 132 if (handler != null) throw new NotSupportedException("Cancel request was ignored."); 133 else handler(this, EventArgs.Empty); 136 134 } 137 135 #endregion
Note: See TracChangeset
for help on using the changeset viewer.