Changeset 12949
- Timestamp:
- 09/14/15 14:28:38 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434/HeuristicLab.Optimization/3.3/MetaOptimizers/Experiment.cs
r12504 r12949 24 24 using System.Drawing; 25 25 using System.Linq; 26 using System.Threading; 26 27 using HeuristicLab.Collections; 27 28 using HeuristicLab.Common; … … 345 346 346 347 private readonly object locker = new object(); 348 private readonly object runsLocker = new object(); 347 349 private void optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) { 348 350 lock (locker) … … 350 352 } 351 353 private void optimizer_ExecutionTimeChanged(object sender, EventArgs e) { 352 lock (locker) 353 ExecutionTime = Optimizers.Aggregate(TimeSpan.Zero, (t, o) => t + o.ExecutionTime); 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 ExecutionTime = Optimizers.Aggregate(TimeSpan.Zero, (t, o) => t + o.ExecutionTime); 358 Monitor.Exit(locker); 354 359 } 355 360 private void optimizer_Paused(object sender, EventArgs e) { … … 378 383 } 379 384 private void optimizer_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 380 lock ( locker) {385 lock (runsLocker) { 381 386 Runs.RemoveRange(e.OldItems); 382 387 Runs.AddRange(e.Items); … … 384 389 } 385 390 private void optimizer_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 386 lock ( locker)391 lock (runsLocker) 387 392 Runs.AddRange(e.Items); 388 393 } 389 394 private void optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 390 lock ( locker)395 lock (runsLocker) 391 396 Runs.RemoveRange(e.Items); 392 397 }
Note: See TracChangeset
for help on using the changeset viewer.