Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/14/15 10:57:49 (9 years ago)
Author:
gkronber
Message:

#2061: merged r12948:12950 from branch to trunk

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Optimization

  • trunk/sources/HeuristicLab.Optimization/3.3/MetaOptimizers/Experiment.cs

    r12504 r13000  
    2424using System.Drawing;
    2525using System.Linq;
     26using System.Threading;
    2627using HeuristicLab.Collections;
    2728using HeuristicLab.Common;
     
    345346
    346347    private readonly object locker = new object();
     348    private readonly object runsLocker = new object();
    347349    private void optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    348350      lock (locker)
     
    350352    }
    351353    private void optimizer_ExecutionTimeChanged(object sender, EventArgs e) {
    352       lock (locker)
     354      // only wait for maximally 100ms to acquire lock, otherwise return and don't update the execution time
     355      var success = Monitor.TryEnter(locker, 100);
     356      if (!success) return;
     357      try {
    353358        ExecutionTime = Optimizers.Aggregate(TimeSpan.Zero, (t, o) => t + o.ExecutionTime);
     359      }
     360      finally {
     361        Monitor.Exit(locker);
     362      }
    354363    }
    355364    private void optimizer_Paused(object sender, EventArgs e) {
     
    378387    }
    379388    private void optimizer_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    380       lock (locker) {
     389      lock (runsLocker) {
    381390        Runs.RemoveRange(e.OldItems);
    382391        Runs.AddRange(e.Items);
     
    384393    }
    385394    private void optimizer_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    386       lock (locker)
     395      lock (runsLocker)
    387396        Runs.AddRange(e.Items);
    388397    }
    389398    private void optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    390       lock (locker)
     399      lock (runsLocker)
    391400        Runs.RemoveRange(e.Items);
    392401    }
Note: See TracChangeset for help on using the changeset viewer.