Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13354


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

#2258: improved cancellation support

Location:
branches/Async
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Async/HeuristicLab.Algorithms.Benchmarks/3.3/BenchmarkAlgorithm.cs

    r13349 r13354  
    305305    }
    306306    public async Task StartAsync() {
    307       await StartAsync(new CancellationToken());
     307      await StartAsync(CancellationToken.None);
    308308    }
    309309    public async Task StartAsync(CancellationToken cancellationToken) {
  • 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) {
  • branches/Async/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs

    r13349 r13354  
    255255    }
    256256    public async Task StartAsync() {
    257       await StartAsync(new CancellationToken());
     257      await StartAsync(CancellationToken.None);
    258258    }
    259259    public async Task StartAsync(CancellationToken cancellationToken) {
  • branches/Async/HeuristicLab.Core/3.3/Executable.cs

    r13349 r13354  
    8888    }
    8989    public async Task StartAsync() {
    90       await StartAsync(new CancellationToken());
     90      await StartAsync(CancellationToken.None);
    9191    }
    9292    public virtual async Task StartAsync(CancellationToken cancellationToken) {
  • branches/Async/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs

    r13349 r13354  
    208208    }
    209209    public async Task StartAsync() {
    210       await StartAsync(new CancellationToken());
     210      await StartAsync(CancellationToken.None);
    211211    }
    212212    public virtual async Task StartAsync(CancellationToken cancellationToken) {
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/BatchRun.cs

    r13349 r13354  
    4242  public sealed class BatchRun : NamedItem, IOptimizer, IStorableContent {
    4343    private readonly ManualResetEvent signaler = new ManualResetEvent(true);
     44    private CancellationToken cancellationToken;
    4445
    4546    public string Filename { get; set; }
     
    251252    }
    252253    public async Task StartAsync() {
    253       await StartAsync(new CancellationToken());
     254      await StartAsync(CancellationToken.None);
    254255    }
    255256    public async Task StartAsync(CancellationToken cancellationToken) {
     257      this.cancellationToken = cancellationToken;
    256258      signaler.Reset();
    257259      await Task.Run(async () => {
     
    413415      else if (batchRunAction == BatchRunAction.Start) {
    414416        Optimizer.Prepare();
    415         Optimizer.StartAsync();
     417        Optimizer.StartAsync(cancellationToken);
    416418      } else if (executionState == ExecutionState.Started) {
    417419        // if the batch run hasn't been started but the inner optimizer was run then pause
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/Experiment.cs

    r13349 r13354  
    4040  public sealed class Experiment : NamedItem, IOptimizer, IStorableContent {
    4141    private readonly ManualResetEvent signaler = new ManualResetEvent(true);
     42    private CancellationToken cancellationToken;
    4243
    4344    public string Filename { get; set; }
     
    192193    }
    193194    public async Task StartAsync() {
    194       await StartAsync(new CancellationToken());
     195      await StartAsync(CancellationToken.None);
    195196    }
    196197    public async Task StartAsync(CancellationToken cancellationToken) {
     198      this.cancellationToken = cancellationToken;
    197199      signaler.Reset();
    198200      await Task.Run(async () => {
     
    395397        } else {
    396398          if (experimentStarted && Optimizers.Any(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused))) {
    397             Optimizers.First(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)).StartAsync();
     399            Optimizers.First(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)).StartAsync(cancellationToken);
    398400          } else if (Optimizers.All(x => x.ExecutionState == ExecutionState.Stopped)) OnStopped();
    399401          else if (Optimizers.Any(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)) && Optimizers.All(o => o.ExecutionState != ExecutionState.Started)) OnPaused();
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs

    r13349 r13354  
    244244    }
    245245    public async Task StartAsync() {
    246       await StartAsync(new CancellationToken());
     246      await StartAsync(CancellationToken.None);
    247247    }
    248248    public async Task StartAsync(CancellationToken cancellationToken) {
Note: See TracChangeset for help on using the changeset viewer.