Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/26/17 09:45:36 (7 years ago)
Author:
jkarder
Message:

#2258: refactored async methods

  • synchronously called IExecutables are now executed in the caller's thread
  • removed old synchronization code from unit tests
Location:
branches/Async/HeuristicLab.Clients.OKB/3.3/RunCreation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Async/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyAlgorithm.cs

    r13349 r15065  
    2121
    2222using System;
    23 using System.Threading;
    24 using System.Threading.Tasks;
    2523using HeuristicLab.Common;
    2624using HeuristicLab.Core;
     
    8280      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot prepare an EmptyAlgorithm." : exceptionMessage);
    8381    }
    84     public override async Task StartAsync(CancellationToken cancellationToken) {
     82    public override void Start() {
    8583      throw new InvalidOperationException(string.IsNullOrEmpty(exceptionMessage) ? "Cannot start an EmptyAlgorithm." : exceptionMessage);
    8684    }
  • branches/Async/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs

    r13354 r15065  
    252252    }
    253253    public void Start() {
    254       StartAsync().Wait();
    255     }
    256     public async Task StartAsync() {
    257       await StartAsync(CancellationToken.None);
    258     }
    259     public async Task StartAsync(CancellationToken cancellationToken) {
     254      Start(CancellationToken.None);
     255    }
     256    public void Start(CancellationToken cancellationToken) {
    260257      CheckUserPermissions();
    261258      if (!ClientInformation.Instance.ClientExists && storeRunsAutomatically) {
    262259        throw new MissingClientRegistrationException();
    263260      }
    264       await Algorithm.StartAsync(cancellationToken);
     261      Algorithm.Start(cancellationToken);
     262    }
     263    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
     264    public async Task StartAsync(CancellationToken cancellationToken) {
     265      await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
    265266    }
    266267    public void Pause() {
Note: See TracChangeset for help on using the changeset viewer.