Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15232


Ignore:
Timestamp:
07/13/17 15:53:56 (7 years ago)
Author:
jkarder
Message:

#2258: worked on exception handling

Location:
branches/Async
Files:
1 added
13 edited

Legend:

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

    r15065 r15232  
    312312      } catch (OperationCanceledException) {
    313313      } catch (AggregateException ae) {
    314         if (ae.InnerExceptions.Count == 1) OnExceptionOccurred(ae.InnerExceptions[0]);
    315         else OnExceptionOccurred(ae);
     314        OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae);
    316315      } catch (Exception e) {
    317316        OnExceptionOccurred(e);
     
    324323    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    325324    public async Task StartAsync(CancellationToken cancellationToken) {
    326       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     325      await AsyncHelper.DoAsync(Start, cancellationToken);
    327326    }
    328327
  • branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r15216 r15232  
    344344    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    345345    public async Task StartAsync(CancellationToken cancellationToken) {
    346       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     346      await AsyncHelper.DoAsync(Start, cancellationToken);
    347347    }
    348348
  • branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/FixedDataAnalysisAlgorithm.cs

    r15065 r15232  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Threading;
    2425using HeuristicLab.Common;
     
    7778      } catch (OperationCanceledException) {
    7879      } catch (AggregateException ae) {
    79         if (ae.InnerExceptions.Count == 1) OnExceptionOccurred(ae.InnerExceptions[0]);
    80         else OnExceptionOccurred(ae);
     80        OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae);
    8181      } catch (Exception e) {
    8282        OnExceptionOccurred(e);
  • branches/Async/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs

    r15065 r15232  
    6969            try {
    7070              algorithm.Problem = problem;
    71             }
    72             catch (ArgumentException) {
     71            } catch (ArgumentException) {
    7372              algorithm.Problem = null;
    7473            }
     
    263262    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    264263    public async Task StartAsync(CancellationToken cancellationToken) {
    265       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     264      await AsyncHelper.DoAsync(Start, cancellationToken);
    266265    }
    267266    public void Pause() {
  • branches/Async/HeuristicLab.Common/3.3/HeuristicLab.Common-3.3.csproj

    r12292 r15232  
    123123  </ItemGroup>
    124124  <ItemGroup>
     125    <Compile Include="AsyncHelper.cs" />
    125126    <Compile Include="CancelEventArgs.cs" />
    126127    <None Include="Plugin.cs.frame" />
  • branches/Async/HeuristicLab.Core/3.3/Engine.cs

    r15065 r15232  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Threading;
    2526using HeuristicLab.Common;
     
    9091      } catch (OperationCanceledException) {
    9192      } catch (AggregateException ae) {
    92         if (ae.InnerExceptions.Count == 1) OnExceptionOccurred(ae.InnerExceptions[0]);
    93         else OnExceptionOccurred(ae);
     93        OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae);
    9494      } catch (Exception e) {
    9595        OnExceptionOccurred(e);
  • branches/Async/HeuristicLab.Core/3.3/Executable.cs

    r15065 r15232  
    9393    public virtual async Task StartAsync() { await StartAsync(CancellationToken.None); }
    9494    public virtual async Task StartAsync(CancellationToken cancellationToken) {
    95       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     95      await AsyncHelper.DoAsync(Start, cancellationToken);
    9696    }
    9797    public virtual void Pause() {
  • branches/Async/HeuristicLab.DebugEngine/3.3/DebugEngine.cs

    r15065 r15232  
    181181      } catch (OperationCanceledException) {
    182182      } catch (AggregateException ae) {
    183         if (ae.InnerExceptions.Count == 1) OnExceptionOccurred(ae.InnerExceptions[0]);
    184         else OnExceptionOccurred(ae);
     183        OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae);
    185184      } catch (Exception e) {
    186185        OnExceptionOccurred(e);
  • branches/Async/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs

    r15065 r15232  
    213213    public virtual async Task StartAsync() { await StartAsync(CancellationToken.None); }
    214214    public virtual async Task StartAsync(CancellationToken cancellationToken) {
    215       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     215      await AsyncHelper.DoAsync(Start, cancellationToken);
    216216    }
    217217    public virtual void Pause() {
  • branches/Async/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs

    r15215 r15232  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Threading;
    2425using HeuristicLab.Common;
     
    6970      } catch (OperationCanceledException) {
    7071      } catch (AggregateException ae) {
    71         if (ae.InnerExceptions.Count == 1) OnExceptionOccurred(ae.InnerExceptions[0]);
    72         else OnExceptionOccurred(ae);
     72        OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae);
    7373      } catch (Exception e) {
    7474        OnExceptionOccurred(e);
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/BatchRun.cs

    r15065 r15232  
    262262    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    263263    public async Task StartAsync(CancellationToken cancellationToken) {
    264       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     264      await AsyncHelper.DoAsync(Start, cancellationToken);
    265265    }
    266266    public void Pause() {
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/Experiment.cs

    r15065 r15232  
    204204    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    205205    public async Task StartAsync(CancellationToken cancellationToken) {
    206       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     206      await AsyncHelper.DoAsync(Start, cancellationToken);
    207207    }
    208208    public void Pause() {
  • branches/Async/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs

    r15065 r15232  
    246246    public async Task StartAsync() { await StartAsync(CancellationToken.None); }
    247247    public async Task StartAsync(CancellationToken cancellationToken) {
    248       await Task.Factory.StartNew((ct) => Start((CancellationToken)ct), cancellationToken, cancellationToken);
     248      await AsyncHelper.DoAsync(Start, cancellationToken);
    249249    }
    250250    public void Pause() {
Note: See TracChangeset for help on using the changeset viewer.