// Algorithms public void Best_First_Search_Alg() { Clear(); List <Field> fieldList = new List <Field>(); foreach (Field field in fieldArray) { field.prevField = null; field.visited = false; field.distance = int.MaxValue; field.fDistance = 0; if (field.finish) { continue; } if (!field.wall) { field.hDistance = field.point.Distance_To(finishPoint); } fieldList.Add(field); if (!field.wall && !field.start && !field.finish) { btnArray[field.point.row, field.point.col].Background = Brushes.White; } } var fieldToVisit = new List <Field>(fieldList); BestFirstSearch alg = new BestFirstSearch(fieldToVisit); thr = new Thread(() => alg.Algorithm()); thr.Start(); }