- Timestamp:
- 12/08/11 18:53:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r7068 r7156 32 32 using HeuristicLab.Optimization; 33 33 using HeuristicLab.PluginInfrastructure; 34 using System.Threading.Tasks; 34 35 35 36 namespace HeuristicLab.Clients.Hive.JobManager.Views { … … 316 317 SetEnabledStateOfControls(); 317 318 } 318 } 319 319 } 320 320 321 321 private void UpdateStateLogList() { … … 336 336 if (nameTextBox.Text.Trim() == string.Empty) { 337 337 MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 338 } else if (Content.ExecutionState == ExecutionState.Paused) { 339 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); 340 task.ContinueWith((t) => { 341 FinishProgressView(); 342 MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 343 Content.Log.LogException(t.Exception); 344 }, TaskContinuationOptions.OnlyOnFaulted); 338 345 } else { 339 346 HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); 340 347 } 341 348 } 349 342 350 private void pauseButton_Click(object sender, EventArgs e) { 343 HiveClient.PauseJob(Content); 344 } 351 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content); 352 task.ContinueWith((t) => { 353 FinishProgressView(); 354 MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 355 Content.Log.LogException(t.Exception); 356 }, TaskContinuationOptions.OnlyOnFaulted); 357 } 358 345 359 private void stopButton_Click(object sender, EventArgs e) { 346 HiveClient.StopJob(Content); 360 var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content); 361 task.ContinueWith((t) => { 362 FinishProgressView(); 363 MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 364 Content.Log.LogException(t.Exception); 365 }, TaskContinuationOptions.OnlyOnFaulted); 347 366 } 348 367 private void resetButton_Click(object sender, EventArgs e) { } 368 369 private void PauseJobAsync(object job) { 370 IProgress prog = new Progress(); 371 prog.Status = "Pausing job..."; 372 SetProgressView(prog); 373 HiveClient.PauseJob((RefreshableJob)job); 374 FinishProgressView(); 375 } 376 377 private void StopJobAsync(object job) { 378 IProgress prog = new Progress(); 379 prog.Status = "Stopping job..."; 380 SetProgressView(prog); 381 HiveClient.StopJob((RefreshableJob)job); 382 FinishProgressView(); 383 } 384 385 private void ResumeJobAsync(object job) { 386 IProgress prog = new Progress(); 387 prog.Status = "Resuming job..."; 388 SetProgressView(prog); 389 HiveClient.ResumeJob((RefreshableJob)job); 390 FinishProgressView(); 391 } 349 392 350 393 private void nameTextBox_Validated(object sender, EventArgs e) { … … 385 428 } 386 429 } 387 388 389 430 #endregion 390 431 … … 394 435 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false; 395 436 } else { 396 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && Content.ExecutionState == ExecutionState.Prepared;437 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused); 397 438 pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started; 398 439 stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started; … … 416 457 417 458 private void SetProgressView() { 418 if (progressView == null) { 419 progressView = new ProgressView(this, Content.Progress); 420 } 421 progressView.Progress = Content.Progress; 459 if (InvokeRequired) { 460 Invoke(new Action(SetProgressView)); 461 } else { 462 if (progressView == null) { 463 progressView = new ProgressView(this, Content.Progress); 464 } else { 465 progressView.Progress = Content.Progress; 466 } 467 } 468 } 469 470 private void SetProgressView(IProgress progress) { 471 if (InvokeRequired) { 472 Invoke(new Action<IProgress>(SetProgressView), progress); 473 } else { 474 if (progressView == null) { 475 progressView = new ProgressView(this, progress); 476 } else { 477 progressView.Progress = progress; 478 } 479 } 422 480 } 423 481 424 482 private void FinishProgressView() { 425 if (progressView != null) { 426 progressView.Finish(); 427 progressView = null; 428 SetEnabledStateOfControls(); 483 if (InvokeRequired) { 484 Invoke(new Action(FinishProgressView)); 485 } else { 486 if (progressView != null) { 487 progressView.Finish(); 488 progressView = null; 489 SetEnabledStateOfControls(); 490 } 429 491 } 430 492 }
Note: See TracChangeset
for help on using the changeset viewer.