internal void UpdatedCompetitorResult(Structs.CompetitorResult compResult) { lock (resultHolders) { resultHolders.Clear(); } }
private void timerAddResults() { try { lock (timerAddResultsRunningLock) { if (timerAddResultsRunning) { return; } timerAddResultsRunning = true; } Trace.WriteLine("timerAddResults_Tick on Thread \"" + Thread.CurrentThread.Name + "\" " + Thread.CurrentThread.ManagedThreadId.ToString()); bool retry = true; Structs.Competitor comp = new Structs.Competitor(); while (retry) { Structs.Competitor[] comps = CommonCode.GetCompetitors(); if (comps.Length == 0) { return; } comp = comps[rnd.Next(comps.Length)]; Structs.CompetitorResult[] results; try { results = CommonCode.GetCompetitorResults(comp.CompetitorId); if (results.Length < 2) { retry = false; } } catch (Exception exc) { Trace.WriteLine(exc.ToString()); retry = false; } } Structs.Station[] stations = CommonCode.GetStations(); foreach (Structs.Station station in stations) { Structs.CompetitorResult res = new Structs.CompetitorResult(); res.CompetitorId = comp.CompetitorId; res.FigureHits = rnd.Next(station.Figures); res.Hits = rnd.Next(station.Shoots); res.Points = 0; res.Station = station.StationId; res.StationFigureHits = res.Hits.ToString() + ";"; CommonCode.NewCompetitorResult(res); } } finally { timerAddResultsRunning = false; } }