private float GetBestFitness() { bool taken = false; FitnessLock.Enter(ref taken); var ret = BestFitness; FitnessLock.Exit(true); return(ret); }
private void Root_FitnessFunctionEvaluated(Job job, int gen, float fitness) { bool taken = false; if (Maximize) { FitnessLock.Enter(ref taken); if (BestFitness < fitness) { BestFitness = fitness; } FitnessLock.Exit(true); } else { FitnessLock.Enter(ref taken); if (BestFitness > fitness) { BestFitness = fitness; } FitnessLock.Exit(true); } }