Example #1
0
        private void FetchGameList()
        {     
            if ((DateTime.Now.Hour > 1 && DateTime.Now.Hour < 9) && games.Count > 0)
            {
                System.Console.WriteLine("Flushing games and downloading new schedule...");

                foreach (NHLGame game in games)
                {
                    game.Shutdown();
                }

                games.Clear();
                stats.UpdateSchedule();
            }
            else
            {
                NHLDotComFetch fetch = new NHLDotComFetch();

                DateTime cStart = DateTime.Now;
                List<int> gameIds = fetch.FetchGameIndex(DateTime.Now);
                TimeSpan cDiff = DateTime.Now - cStart;
                System.Console.WriteLine(String.Format("Took {0} s for FetchGameIndex download", cDiff.TotalSeconds));

                foreach (int i in gameIds)
                {
                    NHLGame game = null;
                    bool gameAlreadyExists = false;

                    foreach (NHLGame existingGame in games)
                    {
                        if (existingGame.GameId == i)
                        {
                            gameAlreadyExists = true;
                            break;
                        }
                    }

                    if (!gameAlreadyExists)
                    {
                        game = new NHLGame(i);
                        games.Add(game);
                        game.StartMonitoring(stats);
                        System.Console.WriteLine("Adding game {0}", i);
                    }
                }
            }

        }