- Timestamp:
- 06/29/12 23:12:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r8160 r8165 31 31 [Content(typeof(OptimizerHiveTask), true)] 32 32 public partial class OptimizerHiveTaskView : HiveTaskView { 33 private ProgressView progressView; 34 private IProgress progress; 33 private Progress progress; 35 34 36 35 public new OptimizerHiveTask Content { … … 45 44 public OptimizerHiveTaskView() { 46 45 InitializeComponent(); 47 progressView = new ProgressView(this); 46 progress = new Progress() { 47 CanBeCanceled = false 48 }; 48 49 } 49 50 … … 76 77 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync); 77 78 task.ContinueWith((t) => { 78 FinishProgressView();79 progress.Finish(); 79 80 ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception); 80 81 }, TaskContinuationOptions.OnlyOnFaulted); … … 84 85 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync); 85 86 task.ContinueWith((t) => { 86 FinishProgressView();87 progress.Finish(); 87 88 ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception); 88 89 }, TaskContinuationOptions.OnlyOnFaulted); … … 92 93 var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync); 93 94 task.ContinueWith((t) => { 94 FinishProgressView();95 progress.Finish(); 95 96 ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception); 96 97 }, TaskContinuationOptions.OnlyOnFaulted); … … 99 100 100 101 private void PauseTaskAsync() { 101 progress = new Progress();102 102 progress.Status = "Pausing task. Please be patient for the command to take effect."; 103 SetProgressView(progress); 104 Content.Pause(); 105 FinishProgressView(); 103 progress.ProgressState = ProgressState.Started; 104 using (var view = new ProgressView(this, progress)) { 105 Content.Pause(); 106 } 106 107 } 107 108 108 109 private void StopTaskAsync() { 109 progress = new Progress();110 110 progress.Status = "Stopping task. Please be patient for the command to take effect."; 111 SetProgressView(progress); 112 Content.Stop(); 113 FinishProgressView(); 111 progress.ProgressState = ProgressState.Started; 112 using (var view = new ProgressView(this, progress)) { 113 Content.Stop(); 114 } 114 115 } 115 116 116 117 private void ResumeTaskAsync() { 117 progress = new Progress();118 118 progress.Status = "Resuming task. Please be patient for the command to take effect."; 119 SetProgressView(progress); 120 Content.Restart(); 121 FinishProgressView(); 122 } 123 124 private void SetProgressView(IProgress progress) { 125 if (InvokeRequired) { 126 Invoke(new Action<IProgress>(SetProgressView), progress); 127 } else { 128 progressView.Progress = progress; 129 } 130 } 131 132 private void FinishProgressView() { 133 if (InvokeRequired) { 134 Invoke(new Action(FinishProgressView)); 135 } else { 136 progress.Finish(); 119 progress.ProgressState = ProgressState.Started; 120 using (var view = new ProgressView(this, progress)) { 121 Content.Restart(); 137 122 } 138 123 }
Note: See TracChangeset
for help on using the changeset viewer.