Exemple #1
0
        private static void CreateCacheReaders(ResultsCache cache, int nReaders)
        {
            for (int nThreads = 0; nThreads < nReaders; nThreads++)
            {
                Thread t = new Thread(ResultsReader);
                t.IsBackground = true;

                t.Start(cache);
            }
        }
Exemple #2
0
        private static void CreateCacheReaders(ResultsCache cache, int nReaders)
        {
            for (int nThreads = 0; nThreads < nReaders; nThreads++)
            {
                Thread t = new Thread(ResultsReader);
                t.IsBackground = true;

                t.Start(cache);
            }
        }
Exemple #3
0
        private static void AddFantasyResult(ResultsCache cache,bool showResult)
        {
            int firstTeam = 0;
            int secondTeam = 0;
            while (firstTeam == secondTeam)
            {
                firstTeam = rnd.Next(Teams.Length);
                secondTeam = rnd.Next(Teams.Length);
            }

            MatchResult result = new MatchResult { FirstTeam = Teams[firstTeam], SecondTeam = Teams[secondTeam], FirstTeamScore = rnd.Next(5), SecondTeamScore = rnd.Next(5) };

            if (showResult)
            {
                Console.SetCursorPosition(0, 1);
                Console.WriteLine("Result just in {0}                                                          ", result.ToString());
            }

            cache.AddResult(result);
        }
Exemple #4
0
        private static void ResultsReader(object o)
        {
            Stopwatch    timer    = Stopwatch.StartNew();
            long         nResults = 0;
            ResultsCache cache    = (ResultsCache)o;

            while (true)
            {
                for (int i = 0; i < 1000; i++)
                {
                    foreach (MatchResult result in cache.GetResults("Germany"))
                    {
                        nResults++;
                    }
                }

                Console.SetCursorPosition(0, 4 + Thread.CurrentThread.ManagedThreadId);
                Console.WriteLine("Speed : {0} Results/s      ", (double)nResults / timer.ElapsedMilliseconds);
            }
        }
Exemple #5
0
        private static void AddFantasyResult(ResultsCache cache, bool showResult)
        {
            int firstTeam  = 0;
            int secondTeam = 0;

            while (firstTeam == secondTeam)
            {
                firstTeam  = rnd.Next(Teams.Length);
                secondTeam = rnd.Next(Teams.Length);
            }

            MatchResult result = new MatchResult {
                FirstTeam = Teams[firstTeam], SecondTeam = Teams[secondTeam], FirstTeamScore = rnd.Next(5), SecondTeamScore = rnd.Next(5)
            };

            if (showResult)
            {
                Console.SetCursorPosition(0, 1);
                Console.WriteLine("Result just in {0}                                                          ", result.ToString());
            }

            cache.AddResult(result);
        }