// check and return status
 private static TimeServiceStatus CheckResults(uint tolerance, DateTime ntpTime)
 {
     if (ntpTime == DateTime.MinValue)
     {
         // fail: call failEvent
         status.Flags = TimeServiceStatus.TimeServiceStatusFlags.SyncFailed;
         TimeSyncFailedEventArgs failEvent = new TimeSyncFailedEventArgs(DateTime.Now, errorCode);
         TimeSyncFailed(null, failEvent);
     }
     else
     {
         // succeed: if (change > tolerance) then set time & call changed Event
         status.Flags = TimeServiceStatus.TimeServiceStatusFlags.SyncSucceeded;
         TimeSpan syncTimeOffset = DateTime.Now - ntpTime;
         status.SyncTimeOffset = (syncTimeOffset.Ticks / TimeSpan.TicksPerMillisecond);
         if (System.Math.Abs(status.SyncTimeOffset) > tolerance)
         {
             SetUtcTime(ntpTime.Ticks);
             SystemTimeChangedEventArgs changedEvent = new SystemTimeChangedEventArgs(DateTime.Now);
             SystemTimeChanged(null, changedEvent);
         }
         SystemTimeChangedEventArgs checkedEvent = new SystemTimeChangedEventArgs(DateTime.Now);
         SystemTimeChecked(null, checkedEvent);
     }
     return(status);
 }
        internal static void OnTimeServiceEventCallback(TimeServiceEvent timeServiceEvent)
        {
            switch (timeServiceEvent.EventType)
            {
            case TimeServiceEventType.SystemTimeChanged:
            {
                if (SystemTimeChanged != null)
                {
                    SystemTimeChangedEventArgs args = new SystemTimeChangedEventArgs(timeServiceEvent.EventTime);

                    SystemTimeChanged(null, args);
                }
                break;
            }

            case TimeServiceEventType.TimeSyncFailed:
            {
                if (TimeSyncFailed != null)
                {
                    TimeSyncFailedEventArgs args = new TimeSyncFailedEventArgs(timeServiceEvent.EventTime, timeServiceEvent.Status);

                    TimeSyncFailed(null, args);
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }
 void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
     syncEvent.Set();
 }
 void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
     Debug.Print("Error synchronizing system time with NTP server: " + e.ErrorCode);
 }
 void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs evt)
 {
     string errorMsg = "Time Sync Failed with errorCode: " + evt.ErrorCode.ToString();
     Debug.Print(errorMsg);
 }
Exemple #6
0
 /// <summary>
 /// TimeService TimeSyncFailed Event, incase theres trouble with TimeService, event gets called
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">TimeSyncFailedEvent Arguments</param>
 private void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
     //Write out error
     Debug.Print(e.EventTime + " NTP Error: Error Syncronizing - " + e.ErrorCode);
 }
Exemple #7
0
 // Called on unsuccessful NTP Synchronization
 private void OnTimeSyncFailed(Object sender, TimeSyncFailedEventArgs e)
 {
     Debug.Print("NTPService : Error synchronizing system time with NTP server");
 }
 private void OnTimeSyncFailed(Object sender, TimeSyncFailedEventArgs e)
 // Called on unsuccessful NTP Synchronization
 {
     Debug.Print("NTPService : Error synchronizing system time with NTP server");
 }
        internal static void OnTimeServiceEventCallback(TimeServiceEvent timeServiceEvent)
        {
            switch (timeServiceEvent.EventType)
            {
                case TimeServiceEventType.SystemTimeChanged:
                    {
                        if (SystemTimeChanged != null)
                        {
                            SystemTimeChangedEventArgs args = new SystemTimeChangedEventArgs(timeServiceEvent.EventTime);

                            SystemTimeChanged(null, args);
                        }
                        break;
                    }
                case TimeServiceEventType.TimeSyncFailed:
                    {
                        if (TimeSyncFailed != null)
                        {
                            TimeSyncFailedEventArgs args = new TimeSyncFailedEventArgs(timeServiceEvent.EventTime, timeServiceEvent.Status);

                            TimeSyncFailed(null, args);
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        }
Exemple #10
0
 void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
     Debug.Print("DateTime Sync Failed");
 }
 private static void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
 }
Exemple #12
0
 void TimeService_TimeSyncFailed(object sender, TimeSyncFailedEventArgs e)
 {
     Debug.Print("Failed time sync." + e.ErrorCode);
 }