Beispiel #1
0
        public MainViewModel()
        {
            _count = CurrentTimeProvider.GetCurrentCounter();
            _time  = CurrentTimeProvider.Period - CurrentTimeProvider.GetCurrentTime();

            ConfigurationStorage.Section.Items.OfType <AuthenticationItem>().ToList().ForEach(i => _items.Add(new ItemViewModel(i)));
            _items.ToList().ForEach(i => i.UpdateCode(_count));

            _timer = new Timer(DoOnEachTimerTick, null, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(50));
        }
Beispiel #2
0
        private void DoOnEachTimerTick(object state)
        {
            try
            {
                Dispatcher.CurrentDispatcher.Invoke(() =>
                {
                    Time = CurrentTimeProvider.Period - CurrentTimeProvider.GetCurrentTime();

                    var count = CurrentTimeProvider.GetCurrentCounter();
                    if (_count != count)
                    {
                        _count = count;
                        _items.ToList().ForEach(i => i.UpdateCode(_count));
                    }
                });
            }
            catch
            {
            }
        }