Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/23/12 11:56:09 (12 years ago)
Author:
gkronber
Message:

#1534: introduced synchronization to make sure the algorithm has been started before calling OnStarted in CrossValidation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r8738 r8836  
    2424using System.Drawing;
    2525using System.Linq;
     26using System.Threading;
    2627using HeuristicLab.Collections;
    2728using HeuristicLab.Common;
     
    311312            if (clonedAlgorithm.ExecutionState == ExecutionState.Prepared ||
    312313                clonedAlgorithm.ExecutionState == ExecutionState.Paused) {
    313               clonedAlgorithm.Start();
    314               startedAlgorithms++;
     314
     315              // start and wait until the alg is started
     316              using (var signal = new ManualResetEvent(false)) {
     317                EventHandler signalSetter = (sender, args) => { signal.Set(); };
     318                clonedAlgorithm.Started += signalSetter;
     319                clonedAlgorithm.Start();
     320                signal.WaitOne();
     321                clonedAlgorithm.Started -= signalSetter;
     322
     323                startedAlgorithms++;
     324              }
    315325            }
    316326          }
Note: See TracChangeset for help on using the changeset viewer.