简体   繁体   English

通过WPF客户端应用程序更改系统时间的策略

[英]Strategy to change system time via WPF client application

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? 没关系...但是,为WPF客户端应用程序更改系统本地时间的最佳策略是什么?

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... 或者最好使用附加thread向服务器询问服务器时间并始终更改本地系统时间...

So I don't know which approach is better... 所以我不知道哪种方法更好...

Thanks for any clue. 感谢您提供任何线索。

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). 最好不要完全这样做-它需要管理员特权才能更改系统时间,因此您的程序必须以admin身份运行(在您的情况下可以接受,但通常不是一个好主意)。

It is also requires some effort to correctly adjust for network latency when setting time. 设置时间时,还需要付出一些努力才能正确调整网络延迟。 Please check out how it is normally done, ie starting with NTP - Network Time Protocol . 请检查它是如何正常完成的,即从NTP-网络时间协议开始

One option is to configure windows to check time more often itself instead doing it by hand as it already implements the functionality. 一种选择是将窗口配置为本身更频繁地检查时间,而不是手动执行,因为它已经实现了该功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM