Changeset 15419 for trunk/sources
- Timestamp:
- 10/13/17 14:21:09 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs
r14185 r15419 61 61 } 62 62 63 protected override void OnContentChanged() {63 protected async override void OnContentChanged() { 64 64 base.OnContentChanged(); 65 65 if (Content == null) { … … 67 67 } else { 68 68 hiveExperimentListView.Content = Content.Jobs; 69 if (Content != null) 70 Content.RefreshAsync(new Action<Exception>((Exception ex) => HandleServiceException(ex))); 69 if (Content != null) { 70 try { 71 await System.Threading.Tasks.Task.Run(() => Content.Refresh()); 72 } catch (Exception ex) { 73 HandleServiceException(ex); 74 } 75 } 71 76 } 72 77 } … … 98 103 } 99 104 100 private void refreshButton_Click(object sender, EventArgs e) { 101 Content.RefreshAsync(new Action<Exception>((Exception ex) => HandleServiceException(ex))); 105 private async void refreshButton_Click(object sender, EventArgs e) { 106 try { 107 await System.Threading.Tasks.Task.Run(() => Content.Refresh()); 108 } catch (Exception ex) { 109 HandleServiceException(ex); 110 } 102 111 } 103 112 -
trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r14901 r15419 99 99 jobs.Add(new RefreshableJob(j)); 100 100 } 101 } 102 catch { 101 } catch (NullReferenceException) { 102 // jobs was set to null during ClearHiveClient 103 } catch { 103 104 jobs = null; 104 105 throw; 105 } 106 finally { 106 } finally { 107 107 OnRefreshed(); 108 108 } 109 }110 111 public void RefreshAsync(Action<Exception> exceptionCallback) {112 var call = new Func<Exception>(delegate() {113 try {114 Refresh();115 }116 catch (Exception ex) {117 return ex;118 }119 return null;120 });121 call.BeginInvoke(delegate(IAsyncResult result) {122 Exception ex = call.EndInvoke(result);123 if (ex != null) exceptionCallback(ex);124 }, null);125 109 } 126 110 #endregion … … 146 130 } 147 131 public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken) { 148 var call = new Func<Exception>(delegate () {132 var call = new Func<Exception>(delegate () { 149 133 try { 150 134 Store(item, cancellationToken); 151 } 152 catch (Exception ex) { 135 } catch (Exception ex) { 153 136 return ex; 154 137 } 155 138 return null; 156 139 }); 157 call.BeginInvoke(delegate (IAsyncResult result) {140 call.BeginInvoke(delegate (IAsyncResult result) { 158 141 Exception ex = call.EndInvoke(result); 159 142 if (ex != null) exceptionCallback(ex); … … 294 277 } 295 278 TS.Task.WaitAll(tasks.ToArray()); 296 } 297 finally { 279 } finally { 298 280 refreshableJob.Job.Modified = false; 299 281 refreshableJob.IsProgressing = false; … … 394 376 taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 395 377 TS.Task.WaitAll(tasks.ToArray()); 396 } 397 finally { 378 } finally { 398 379 if (!semaphoreReleased) taskUploadSemaphore.Release(); 399 380 } … … 443 424 } else if (refreshableJob.IsPaused()) { 444 425 refreshableJob.ExecutionState = Core.ExecutionState.Paused; 445 } else { 426 } else { 446 427 refreshableJob.ExecutionState = Core.ExecutionState.Started; 447 428 } 448 429 refreshableJob.OnLoaded(); 449 } 450 finally { 430 } finally { 451 431 refreshableJob.IsProgressing = false; 452 432 refreshableJob.Progress.Finish(); … … 485 465 try { 486 466 return PersistenceUtil.Deserialize<ItemTask>(taskData.Data); 487 } 488 catch { 467 } catch { 489 468 return null; 490 469 } … … 497 476 public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) { 498 477 while (true) { 499 try { action(); return; } 500 catch (Exception e) { 478 try { action(); return; } catch (Exception e) { 501 479 if (repetitions == 0) throw new HiveException(errorMessage, e); 502 480 if (log != null) log.LogMessage(string.Format("{0}: {1} - will try again!", errorMessage, e.ToString()));
Note: See TracChangeset
for help on using the changeset viewer.