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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Async/HeuristicLab.Core/3.3/Executable.cs

    r13354 r15065  
    8484      ExecutionTime = TimeSpan.Zero;
    8585    }
    86     public void Start() {
    87       StartAsync().Wait();
     86    public virtual void Start() {
     87      Start(CancellationToken.None);
    8888    }
    89     public async Task StartAsync() {
    90       await StartAsync(CancellationToken.None);
    91     }
    92     public virtual async Task StartAsync(CancellationToken cancellationToken) {
     89    public virtual void Start(CancellationToken cancellationToken) {
    9390      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
    9491        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
     92    }
     93    public virtual async Task StartAsync() { await StartAsync(CancellationToken.None); }
     94    public virtual async Task StartAsync(CancellationToken cancellationToken) {
     95      await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
    9596    }
    9697    public virtual void Pause() {
Note: See TracChangeset for help on using the changeset viewer.