/// <summary> /// Начать гонку /// </summary> public void StartRace() { IsAllFinished = false; FinishedRacers.Clear(); Racers.ForEach(veh => { veh.Run(Length, TimerInterval); }); CheckForFinish(); }
/// <summary> /// Сама проверка окончания /// </summary> /// <param name="obj"></param> private void CheckDo(object obj) { if (Racers.Count(x => x.IsFinished) == Racers.Count) { _timer.Dispose(); IsAllFinished = true; OnFinishHandler?.Invoke(); //Отсортируем по времени и выведем таблицу var list = Racers.OrderBy(x => x.ElapsedTime).ToList(); for (var i = 0; i < list.Count; i++) { list[i].Place = i + 1; FinishedRacers.Add(list[i]); } } }