Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}

            #region HexClockInit

            HexClock.StrokeThickness = 10; // TODO: it should be a designer property
            Timer hexTimer = new Timer(TimerInterval);
            hexTimer.AutoReset = true;
            hexTimer.Elapsed  += new ElapsedEventHandler((o, e) =>
            {
                HexClock.UpdateNow();
                DecClock.UpdateNow();
            });

            hexTimer.Start();

            #endregion HexClockInit
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}

            #region HexClockInit

            HexClock.StrokeThickness = 10; // TODO: it should be a designer property
            bool            updating = false;
            DispatcherTimer hexTimer = new DispatcherTimer();
            hexTimer.Tick += (sender, e) =>
            {
                //HexClock.UpdateNow();
                if (Monitor.TryEnter(HexClock))
                {
                    try
                    {
                        HexClock.UpdateNow();
                        DecClock.UpdateNow();
                    }
                    finally
                    {
                        Monitor.Exit(HexClock);
                    }
                }
            };
            hexTimer.Interval = TimeSpan.FromMilliseconds(TimerInterval);
            hexTimer.Start();

            #endregion HexClockInit
        }