diff --git a/SafeExamBrowser.UserInterface.Desktop/ViewModels/DateTimeViewModel.cs b/SafeExamBrowser.UserInterface.Desktop/ViewModels/DateTimeViewModel.cs index 36f874c6..caa61049 100644 --- a/SafeExamBrowser.UserInterface.Desktop/ViewModels/DateTimeViewModel.cs +++ b/SafeExamBrowser.UserInterface.Desktop/ViewModels/DateTimeViewModel.cs @@ -8,13 +8,13 @@ using System; using System.ComponentModel; -using System.Timers; +using System.Windows.Threading; namespace SafeExamBrowser.UserInterface.Desktop.ViewModels { internal class DateTimeViewModel : INotifyPropertyChanged { - private Timer timer; + private DispatcherTimer timer; private readonly bool showSeconds; public string Date { get; private set; } @@ -26,12 +26,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.ViewModels public DateTimeViewModel(bool showSeconds) { this.showSeconds = showSeconds; - this.timer = new Timer(1000); - this.timer.Elapsed += Timer_Elapsed; + this.timer = new DispatcherTimer(); + this.timer.Interval = TimeSpan.FromMilliseconds(250); + this.timer.Tick += Timer_Tick; this.timer.Start(); } - private void Timer_Elapsed(object sender, ElapsedEventArgs e) + private void Timer_Tick(object sender, EventArgs e) { var date = DateTime.Now; diff --git a/SafeExamBrowser.UserInterface.Mobile/ViewModels/DateTimeViewModel.cs b/SafeExamBrowser.UserInterface.Mobile/ViewModels/DateTimeViewModel.cs index 5f089aa1..b22b5e28 100644 --- a/SafeExamBrowser.UserInterface.Mobile/ViewModels/DateTimeViewModel.cs +++ b/SafeExamBrowser.UserInterface.Mobile/ViewModels/DateTimeViewModel.cs @@ -8,13 +8,13 @@ using System; using System.ComponentModel; -using System.Timers; +using System.Windows.Threading; namespace SafeExamBrowser.UserInterface.Mobile.ViewModels { internal class DateTimeViewModel : INotifyPropertyChanged { - private Timer timer; + private DispatcherTimer timer; private readonly bool showSeconds; public string Date { get; private set; } @@ -26,12 +26,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.ViewModels public DateTimeViewModel(bool showSeconds) { this.showSeconds = showSeconds; - this.timer = new Timer(1000); - this.timer.Elapsed += Timer_Elapsed; + this.timer = new DispatcherTimer(); + this.timer.Interval = TimeSpan.FromMilliseconds(250); + this.timer.Tick += Timer_Tick; this.timer.Start(); } - private void Timer_Elapsed(object sender, ElapsedEventArgs e) + private void Timer_Tick(object sender, EventArgs e) { var date = DateTime.Now;