コード例 #1
0
 protected void NTPTimeRequest()
 {
     //Try to update time via internet
     this.ntpClient = new NtpClient();
     this.timeReceived_handler = new EventHandler<NtpClient.TimeReceivedEventArgs>(this.ntpClient_TimeReceived);
     this.ntpClient.TimeReceived += this.timeReceived_handler;
     this.ntpClient.RequestTime();
 }
コード例 #2
0
        protected void ntpClient_TimeReceived(object sender, J2i.Net.Ntp.NtpClient.TimeReceivedEventArgs e)
        {
            DateTime currentTime = e.CurrentTime;
            this.NTPTimeOffset = currentTime - DateTime.UtcNow;

            this.ntpClient.TimeReceived -= this.timeReceived_handler;
            this.timeReceived_handler = null;
            this.ntpClient = null;
        }