- Timestamp:
- 06/29/12 23:12:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r8160 r8165 39 39 public new IOptimizer Content { 40 40 get { return (IOptimizer)base.Content; } 41 set { 42 base.Content = value; 43 } 41 set { base.Content = value; } 44 42 } 45 43 … … 56 54 Algorithm selectedAlgorithm = null; 57 55 Problem selectedProblem = null; 58 private ProgressView progressView; 59 private IProgress progress;56 private ProgressView progressView; // this has to be disposed manually! 57 private Progress progress; 60 58 61 59 public OKBExperimentUploadView() { 62 60 InitializeComponent(); 63 progressView = new ProgressView(this); 61 progress = new Progress() { 62 CanBeCanceled = false, 63 ProgressState = ProgressState.Finished 64 }; 64 65 } 65 66 … … 95 96 RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing); 96 97 RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed); 98 progressView = new ProgressView(this, progress); 97 99 } 98 100 … … 100 102 RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing); 101 103 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 104 if (progressView != null) { 105 progressView.Content = null; 106 progressView.Dispose(); 107 progressView = null; 108 } 102 109 base.DeregisterContentEvents(); 103 110 } … … 191 198 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 192 199 } else { 193 progress = new Progress();194 200 progress.Status = "Refreshing algorithms and problems..."; 195 SetProgressView(progress);201 progress.ProgressState = ProgressState.Started; 196 202 } 197 203 } … … 201 207 Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e); 202 208 } else { 203 FinishProgressView();209 progress.Finish(); 204 210 SetEnabledStateOfControls(); 205 211 } … … 209 215 var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync); 210 216 task.ContinueWith((t) => { 211 FinishProgressView();217 progress.Finish(); 212 218 PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception); 213 219 }, TaskContinuationOptions.OnlyOnFaulted); … … 215 221 216 222 private void UploadAsync() { 217 progress = new Progress();218 223 progress.Status = "Uploading runs to OKB..."; 219 224 progress.ProgressValue = 0; … … 221 226 int i = 0; 222 227 223 SetProgressView(progress);224 foreach (DataGridViewRow row in dataGridView.Rows) {225 selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault();226 selectedProblem = problems.Where(x => x.Name == row.Cells[problemColumnIndex].Value.ToString()).FirstOrDefault();227 if (selectedAlgorithm == null || selectedProblem == null) {228 throw new ArgumentException("Can't retrieve the algorithm/problem to upload");229 }230 231 OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id);232 run.Store();233 i++;234 progress.ProgressValue = ((double)i) / count;235 }236 FinishProgressView();228 using (var view = new ProgressView(this, progress)) { 229 foreach (DataGridViewRow row in dataGridView.Rows) { 230 selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault(); 231 selectedProblem = problems.Where(x => x.Name == row.Cells[problemColumnIndex].Value.ToString()).FirstOrDefault(); 232 if (selectedAlgorithm == null || selectedProblem == null) { 233 throw new ArgumentException("Can't retrieve the algorithm/problem to upload"); 234 } 235 236 OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id); 237 run.Store(); 238 i++; 239 progress.ProgressValue = ((double)i) / count; 240 } 241 } 237 242 ClearRuns(); 238 }239 240 private void SetProgressView(IProgress progress) {241 if (InvokeRequired) {242 Invoke(new Action<IProgress>(SetProgressView), progress);243 } else {244 progressView.Progress = progress;245 }246 }247 248 private void FinishProgressView() {249 if (InvokeRequired) {250 Invoke(new Action(FinishProgressView));251 } else {252 progress.Finish();253 }254 243 } 255 244
Note: See TracChangeset
for help on using the changeset viewer.