윈도우 시간 동기화

CSharp
프로그램을 개발하면서 윈도우의 시간동기화가 필수적으로 필요하게 되었습니다. 당연히 윈도우가 자동으로 잘 동기화를 하고 있겠지만은 그렇지 않은 경우에는 강제로 동기화를 해야 하는데, 컴퓨터가 그냥 자동으로 작업을 할 경우에 시간에 예약이 있을 경우에 시간이 동기화가 되지 않으면은 작업이 늦어지기에 한번씩 동기화를 해줘야 합니다. /// <summary> /// Gets the current DateTime from time-a.nist.gov. /// </summary> /// <returns>A DateTime containing the current time.</returns> public static DateTime GetNetworkTime() {     return GetNetworkTime("time.windows.com"); // time-a.nist.gov }   /// <summary> /// Gets the current DateTime from <paramref name="ntpServer"/>. /// </summary> /// <param name="ntpServer">The hostname of the NTP server.</param> /// <returns>A DateTime containing the current time.</returns> public static DateTime GetNetworkTime(string ntpServer) {     IPAddress[] address = Dns.GetHostEntry(ntpServer).AddressList;       if (address == null || address.Length == 0)         throw new ArgumentException("Could not resolve ip address from '" + ntpServer + "'.", "ntpServer");…
Read More