0

I found good advice how to change system time here.

It's ok... But what is the best strategy to change system local time for the WPF client application then?

For example my application periodically gets some data from server and I can pass the server time with it.

Or may be is better to use additional thread to ask server about the server time and change local system time always...

So I don't know which approach is better...

Thanks for any clue.

Community
  • 1
  • 1
NoWar
  • 36,338
  • 80
  • 323
  • 498

1 Answers1

4

It is better not to do it at all - it requires admin privileges to change system time, so your program will have to run as admin (may be acceptable in your case, but normally not a good idea).

It is also requires some effort to correctly adjust for network latency when setting time. Please check out how it is normally done, i.e. starting with NTP - Network Time Protocol.

One option is to configure windows to check time more often itself instead doing it by hand as it already implements the functionality.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • 2
    You can check out [this NTP Snippet](http://dotnet-snippets.com/dns/c-simple-network-time-ntp-protocol-client-SID571.aspx) if you want to go this route – Raj Ranjhan Apr 19 '12 at 17:04