Ejemplo n.º 1
0
        private void CountTimeAndUpdateLabel(ClockStatus clockStatus)
        {
            DateTime startTime = DateTime.Now;

            clockStatus.Status = true;
            while (true)
            {
                lock (clockStatus)
                {
                    if (!clockStatus.Status)
                    {
                        break;
                    }
                    ;
                }
                TimeSpan time = DateTime.Now - startTime;
                int      h = time.Hours, m = time.Minutes;
                string   hours   = (h < 10) ? ("0" + h) : h.ToString();
                string   minutes = (m < 10) ? ("0" + m) : m.ToString();
                Dispatcher.Invoke(() =>
                {
                    TimeLabel.Content = hours + ":" + minutes;
                    //TimeLabel.Content = time.ToString();
                });
            }
        }
Ejemplo n.º 2
0
 public MainWindow()
 {
     InitializeComponent();
     clockStatus = new ClockStatus
     {
         Status = false
     };
 }