Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/16 16:15:10 (8 years ago)
Author:
abeham
Message:

#2457: worked on expert system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/ExpertSystem.cs

    r13713 r13718  
    251251      // It has to be decided somehow which problem instances to include in order to obtain the set of features that is expressive and available
    252252      var allCharacteristics = ProblemInstances.Select(x => new HashSet<string>(x.Results.Where(y => y.Key.StartsWith("Characteristic.", StringComparison.Ordinal)).Select(y => y.Key))).ToList();
     253      if (allCharacteristics.Count == 0) return;
     254
    253255      var commonCharacteristics = filter.Count > 0 ? filter : allCharacteristics[0];
    254256      for (var i = 0; i < allCharacteristics.Count; i++)
     
    446448    }
    447449
    448     public async void UpdateKnowledgeBaseAsync(IProgress progress) {
     450    public Task UpdateKnowledgeBaseAsync(IProgress progress = null) {
     451      if (progress == null) progress = new Progress(string.Empty);
    449452      progress.Start("Updating Knowledge Base from OKB");
    450       await Task.Factory.StartNew(() => { DoUpdateKnowledgeBase(progress); }, TaskCreationOptions.LongRunning);
    451     }
    452 
    453     public void UpdateKnowledgeBase() {
    454       DoUpdateKnowledgeBase(new Progress(string.Empty, ProgressState.Started));
     453      OnDownloadStarted(progress);
     454      return Task.Factory.StartNew(() => { DoUpdateKnowledgeBase(progress); }, TaskCreationOptions.LongRunning);
     455    }
     456
     457    public void UpdateKnowledgeBase(IProgress progress = null) {
     458      UpdateKnowledgeBaseAsync(progress).Wait();
    455459    }
    456460
     
    632636      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    633637    }
     638
     639    public event EventHandler<EventArgs<IProgress>> DownloadStarted;
     640    private void OnDownloadStarted(IProgress progress) {
     641      var handler = DownloadStarted;
     642      if (handler != null) handler(this, new EventArgs<IProgress>(progress));
     643    }
    634644  }
    635645}
Note: See TracChangeset for help on using the changeset viewer.