public void Continue(GantSolution solution, Combination combination) { var solutionVariant = solution.Copy(); solutionVariant.Id = Interlocked.Increment(ref _nextId); solutionVariant.Solutions = this; solutionVariant.Combination = combination; Interlocked.Increment(ref TotalTasks); Interlocked.Increment(ref RunningTasks); Run(() => { solutionVariant.Calculate(); Interlocked.Decrement(ref RunningTasks); }); }
public void Add(GantSolution solutionVariant) { if (solutionVariant.Days >= _solution?.Days) { return; } GantSolution initial; do { initial = _solution; if (solutionVariant.Days >= initial?.Days) { break; } }while (initial != Interlocked.CompareExchange(ref _solution, solutionVariant, initial)); }