Exemplo n.º 1
0
 private void ntpClient_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine(e.CurrentTime);
     System.Diagnostics.Debug.WriteLine("NTP Local: " + e.CurrentTime.ToLocalTime().ToString());
     System.Diagnostics.Debug.WriteLine("Local: " + DateTime.Now.ToString());
     _GotTimeTaskCompletionSource.SetResult(e.CurrentTime);
 }
Exemplo n.º 2
0
		private void ntpClient_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(e.CurrentTime);
			System.Diagnostics.Debug.WriteLine("NTP Local: " + e.CurrentTime.ToLocalTime().ToString());
			System.Diagnostics.Debug.WriteLine("Local: " + DateTime.Now.ToString());
			_GotTimeTaskCompletionSource.SetResult(e.CurrentTime);
		}
Exemplo n.º 3
0
        private static void NtpClient_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
        {
            TimeSpan timeDifference = e.CurrentTime.Subtract(DateTime.UtcNow);

            timeDelta           = (int)Math.Round(timeDifference.TotalSeconds);
            timeDeltaValidUntil = DateTime.UtcNow.AddSeconds(TIME_DELTA_VALID_SECONDS);
            retryCounter        = 0;
        }
Exemplo n.º 4
0
        private void Client_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
        {
            this.buttonPingNTPServer.Visible = true;

            TimeSpan timeDifference = OtpTime.getTime().Subtract(e.CurrentTime);

            this.Invoke((Action)(() =>
            {
                if (-5000 < timeDifference.TotalMilliseconds && timeDifference.TotalMilliseconds < 5000)
                {
                    MessageBox.Show(String.Format(KeeOtp2Statics.TroubleshootingPingResultOk, Math.Round(Math.Abs(timeDifference.TotalMilliseconds)), Math.Round(Math.Abs((float)timeDifference.TotalMilliseconds / 1000), 1), (timeDifference.TotalMilliseconds < 0 ? "behind" : "before")), "NTP Request", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (-30000 < timeDifference.TotalMilliseconds && timeDifference.TotalMilliseconds < 30000)
                {
                    MessageBox.Show(String.Format(KeeOtp2Statics.TroubleshootingPingResultModerate, Math.Round(Math.Abs(timeDifference.TotalMilliseconds)), Math.Round(Math.Abs((float)timeDifference.TotalMilliseconds / 1000), 1), (timeDifference.TotalMilliseconds < 0 ? "behind" : "before")), "NTP Request", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(String.Format(KeeOtp2Statics.TroubleshootingPingResultBad, Math.Round(Math.Abs(timeDifference.TotalMilliseconds)), Math.Round(Math.Abs((float)timeDifference.TotalMilliseconds / 1000), 1), (timeDifference.TotalMilliseconds < 0 ? "behind" : "before")), "NTP Request", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }));
            this.Enabled = true;
        }
Exemplo n.º 5
0
		private void Client_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(e.CurrentTime);
			_Result = e.CurrentTime;
			_GotResultSignal.Set();
		}
Exemplo n.º 6
0
 private void Client_TimeReceived(object sender, NtpTimeReceivedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine(e.CurrentTime);
     _Result = e.CurrentTime;
     _GotResultSignal.Set();
 }