Esempio n. 1
0
        internal async Task AsyncLoadUpdates(string file)
        {
            try
            {
                GameUpdates.SupressNotification = true;
                m_stopwatch = new Stopwatch();
                m_stopwatch.Start();
                OnPropertyChanged(nameof(GameUpdatesDelayedCount));
                using (StreamReader sr = new StreamReader(file))
                {
                    while (!sr.EndOfStream)
                    {
                        string obj = await sr.ReadLineAsync();

                        Update u = JsonSerializer.Deserialize <Update>(obj, s_diskOptions);
                        foreach (var s in u.Schedule)
                        {
                            if (u.clientMeta != null)
                            {
                                s.timestamp = u.clientMeta.timestamp;
                            }
                            GameUpdates.Add(new GameUpdateVm(s, m_teamLookup));
                        }
                        if (m_stopwatch.Elapsed > TimeSpan.FromSeconds(COUNT_DELAY))
                        {
                            OnPropertyChanged(nameof(GameUpdatesDelayedCount));
                            m_stopwatch.Restart();
                        }
                    }
                }
                m_stopwatch.Stop();

                GameUpdates.SupressNotification = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Something invalid happened.", "BLASPHEMY");
            }
        }
Esempio n. 2
0
 internal void AddGame(Game g)
 {
     GameUpdates.Add(new GameUpdateVm(g, m_teamLookup));
     m_convertCommand.RaiseCanExecuteChanged();
 }