首页 新闻 会员 周边

C# 定时器

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-09-16 16:17

我是用的这个定时器,做了一个程序,目前发现一个问题需要大家解决一下,就是启动程序后,定时器每个10秒请求一下服务器,但是电脑如果睡眠后,然后再打开电脑,程序的定时器就会停止,不会再请求服务器,这个办法怎么解决,(再打开的时候继续请求服务器,或者睡眠的时候也请求。)

C#
豌豆夹的主页 豌豆夹 | 初学一级 | 园豆:6
提问于:2015-08-14 16:51
< >
分享
所有回答(3)
0

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx

The time that the system spends in sleep or hibernation does not count toward the expiration of the timer. The timer is signaled when the cumulative amount of elapsed time the system spends in the waking state matches the timer's due time or period.

Windows Server 2003 and Windows XP:  The time that the system spends in sleep or hibernation counts toward the expiration of the timer.  If the timer expires while the system is sleeping, the timer is signaled immediately when the system wakes.

Launcher | 园豆:45045 (高人七级) | 2015-08-14 17:03
1

那就不让电脑休眠不就行了

CodeHsu | 园豆:5468 (大侠五级) | 2015-08-14 19:34
0

你可以使用线程来代替定时器啊,线程是后台运行的。

猿哥爱码 | 园豆:258 (菜鸟二级) | 2015-08-27 00:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册