protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); App.LocalAddress = App.GetMyIPAddress(); if (NetworkInterface.GetIsNetworkAvailable() == false || App.LocalAddress == null) { MessageBox.Show("No available network. Turn on Wifi and try again."); Application.Current.Terminate(); return; } var ntpClient = new NtpClient(); ntpClient.TimeReceived += ntpClient_TimeReceived; ntpClient.RequestTime(); //dispatcherTimer = new DispatcherTimer(); //dispatcherTimer.Interval = TimeSpan.FromSeconds(3); //dispatcherTimer.Tick += (sender, e1) => ntpClient_TimeReceived(null, null); //dispatcherTimer.Start(); timeoutAction = Scheduler.Dispatcher.Schedule(() => ntpClient_TimeReceived(null, null)); }
private void UpdateTimeButton_Click(object sender, RoutedEventArgs e) { _ntpClient.RequestTime(); }