Changeset 15495


Ignore:
Timestamp:
12/06/17 12:33:15 (3 years ago)
Author:
jkarder
Message:

#2846: merged r15419 and r15478 into stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs

    r14186 r15495  
    6161    }
    6262
    63     protected override void OnContentChanged() {
     63    protected async override void OnContentChanged() {
    6464      base.OnContentChanged();
    6565      if (Content == null) {
     
    6767      } else {
    6868        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        }
    7174      }
    7275    }
     
    98101    }
    99102
    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      }
    102109    }
    103110
  • stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15262 r15495  
    9696        var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetJobs());
    9797
    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 {
    103106        jobs = null;
    104107        throw;
    105       }
    106       finally {
     108      } finally {
    107109        OnRefreshed();
    108110      }
    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);
    125111    }
    126112    #endregion
     
    146132    }
    147133    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 () {
    149135        try {
    150136          Store(item, cancellationToken);
    151         }
    152         catch (Exception ex) {
     137        } catch (Exception ex) {
    153138          return ex;
    154139        }
    155140        return null;
    156141      });
    157       call.BeginInvoke(delegate(IAsyncResult result) {
     142      call.BeginInvoke(delegate (IAsyncResult result) {
    158143        Exception ex = call.EndInvoke(result);
    159144        if (ex != null) exceptionCallback(ex);
     
    294279        }
    295280        TS.Task.WaitAll(tasks.ToArray());
    296       }
    297       finally {
     281      } finally {
    298282        refreshableJob.Job.Modified = false;
    299283        refreshableJob.IsProgressing = false;
     
    394378        taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!
    395379        TS.Task.WaitAll(tasks.ToArray());
    396       }
    397       finally {
     380      } finally {
    398381        if (!semaphoreReleased) taskUploadSemaphore.Release();
    399382      }
     
    443426        } else if (refreshableJob.IsPaused()) {
    444427          refreshableJob.ExecutionState = Core.ExecutionState.Paused;
    445         } else { 
     428        } else {
    446429          refreshableJob.ExecutionState = Core.ExecutionState.Started;
    447430        }
    448431        refreshableJob.OnLoaded();
    449       }
    450       finally {
     432      } finally {
    451433        refreshableJob.IsProgressing = false;
    452434        refreshableJob.Progress.Finish();
     
    485467      try {
    486468        return PersistenceUtil.Deserialize<ItemTask>(taskData.Data);
    487       }
    488       catch {
     469      } catch {
    489470        return null;
    490471      }
     
    497478    public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) {
    498479      while (true) {
    499         try { action(); return; }
    500         catch (Exception e) {
     480        try { action(); return; } catch (Exception e) {
    501481          if (repetitions == 0) throw new HiveException(errorMessage, e);
    502482          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.