Changeset 15495
- Timestamp:
- 12/06/17 12:33:15 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15419,15478
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs
r14186 r15495 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 try { 70 await System.Threading.Tasks.Task.Run(() => Content.Refresh()); 71 } catch (Exception ex) { 72 HandleServiceException(ex); 73 } 71 74 } 72 75 } … … 98 101 } 99 102 100 private void refreshButton_Click(object sender, EventArgs e) { 101 Content.RefreshAsync(new Action<Exception>((Exception ex) => HandleServiceException(ex))); 103 private async void refreshButton_Click(object sender, EventArgs e) { 104 try { 105 await System.Threading.Tasks.Task.Run(() => Content.Refresh()); 106 } catch (Exception ex) { 107 HandleServiceException(ex); 108 } 102 109 } 103 110 -
stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15262 r15495 96 96 var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetJobs()); 97 97 98 foreach (var j in jobsLoaded) { 99 jobs.Add(new RefreshableJob(j)); 100 } 101 } 102 catch { 98 try { 99 foreach (var j in jobsLoaded) { 100 jobs.Add(new RefreshableJob(j)); 101 } 102 } catch (NullReferenceException) { 103 // jobs was set to null during ClearHiveClient 104 } 105 } catch { 103 106 jobs = null; 104 107 throw; 105 } 106 finally { 108 } finally { 107 109 OnRefreshed(); 108 110 } 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 111 } 126 112 #endregion … … 146 132 } 147 133 public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken) { 148 var call = new Func<Exception>(delegate () {134 var call = new Func<Exception>(delegate () { 149 135 try { 150 136 Store(item, cancellationToken); 151 } 152 catch (Exception ex) { 137 } catch (Exception ex) { 153 138 return ex; 154 139 } 155 140 return null; 156 141 }); 157 call.BeginInvoke(delegate (IAsyncResult result) {142 call.BeginInvoke(delegate (IAsyncResult result) { 158 143 Exception ex = call.EndInvoke(result); 159 144 if (ex != null) exceptionCallback(ex); … … 294 279 } 295 280 TS.Task.WaitAll(tasks.ToArray()); 296 } 297 finally { 281 } finally { 298 282 refreshableJob.Job.Modified = false; 299 283 refreshableJob.IsProgressing = false; … … 394 378 taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 395 379 TS.Task.WaitAll(tasks.ToArray()); 396 } 397 finally { 380 } finally { 398 381 if (!semaphoreReleased) taskUploadSemaphore.Release(); 399 382 } … … 443 426 } else if (refreshableJob.IsPaused()) { 444 427 refreshableJob.ExecutionState = Core.ExecutionState.Paused; 445 } else { 428 } else { 446 429 refreshableJob.ExecutionState = Core.ExecutionState.Started; 447 430 } 448 431 refreshableJob.OnLoaded(); 449 } 450 finally { 432 } finally { 451 433 refreshableJob.IsProgressing = false; 452 434 refreshableJob.Progress.Finish(); … … 485 467 try { 486 468 return PersistenceUtil.Deserialize<ItemTask>(taskData.Data); 487 } 488 catch { 469 } catch { 489 470 return null; 490 471 } … … 497 478 public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) { 498 479 while (true) { 499 try { action(); return; } 500 catch (Exception e) { 480 try { action(); return; } catch (Exception e) { 501 481 if (repetitions == 0) throw new HiveException(errorMessage, e); 502 482 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.