Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 11:54:35 (5 years ago)
Author:
pfleck
Message:

#2845 Merged trunk changes before source move into branch

Location:
branches/2845_EnhancedProgress
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress

  • branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15477 r16307  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    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);
     
    296281        }
    297282        TS.Task.WaitAll(tasks.ToArray());
    298       }
    299       finally {
     283      } finally {
    300284        refreshableJob.Job.Modified = false;
    301285        refreshableJob.IsProgressing = false;
     
    396380        taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!
    397381        TS.Task.WaitAll(tasks.ToArray());
    398       }
    399       finally {
     382      } finally {
    400383        if (!semaphoreReleased) taskUploadSemaphore.Release();
    401384      }
     
    449432        } else if (refreshableJob.IsPaused()) {
    450433          refreshableJob.ExecutionState = Core.ExecutionState.Paused;
    451         } else { 
     434        } else {
    452435          refreshableJob.ExecutionState = Core.ExecutionState.Started;
    453436        }
    454437        refreshableJob.OnLoaded();
    455       }
    456       finally {
     438      } finally {
    457439        refreshableJob.IsProgressing = false;
    458440        refreshableJob.Progress.Finish();
     
    491473      try {
    492474        return PersistenceUtil.Deserialize<ItemTask>(taskData.Data);
    493       }
    494       catch {
     475      } catch {
    495476        return null;
    496477      }
     
    503484    public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) {
    504485      while (true) {
    505         try { action(); return; }
    506         catch (Exception e) {
     486        try { action(); return; } catch (Exception e) {
    507487          if (repetitions == 0) throw new HiveException(errorMessage, e);
    508488          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.