Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/15 12:20:43 (9 years ago)
Author:
jkarder
Message:

#2258: improved cancellation support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r13349 r13354  
    4141  public sealed class CrossValidation : ParameterizedNamedItem, IAlgorithm, IStorableContent {
    4242    private readonly ManualResetEvent signaler = new ManualResetEvent(true);
     43    private CancellationToken cancellationToken;
    4344
    4445    public CrossValidation()
     
    272273    }
    273274    public async Task StartAsync() {
    274       await StartAsync(new CancellationToken());
     275      await StartAsync(CancellationToken.None);
    275276    }
    276277    public async Task StartAsync(CancellationToken cancellationToken) {
     278      this.cancellationToken = cancellationToken;
    277279      signaler.Reset();
    278280      await Task.Run(() => {
     
    682684          IAlgorithm preparedAlgorithm = clonedAlgorithms.FirstOrDefault(alg => alg.ExecutionState == ExecutionState.Prepared ||
    683685                                                                                alg.ExecutionState == ExecutionState.Paused);
    684           if (preparedAlgorithm != null) preparedAlgorithm.StartAsync();
     686          if (preparedAlgorithm != null) preparedAlgorithm.StartAsync(cancellationToken);
    685687        }
    686688        if (ExecutionState != ExecutionState.Stopped) {
Note: See TracChangeset for help on using the changeset viewer.