public ProcessResult Sync() { ProcessResult result = new ProcessResult(); try { ntp_time = connection.GetUtc(); } catch (Exception e) { result.Success = false; result.Message = e.Message; } return(result); }
public void sync(string host_name) { try { var connection = new NtpConnection(host_name); stop_watch = new Stopwatch(); stop_watch.Stop(); var utcNow = connection.GetUtc(); stop_watch.Start(); time_offset = (long)(utcNow - new DateTime(1970, 1, 1)).TotalMilliseconds; reportLog("NTP Sync successful", LogType.INFO, "NTPClient"); reportLog("Current time is : " + get(), LogType.INFO, "NTPClient"); } catch (Exception e) { string msg = e.Message; reportLog("Error in time sync : " + msg, LogType.ERROR, "NTPClient"); } }