我想在后台有一个计时器 [英] I want have a timer in Background

查看:96
本文介绍了我想在后台有一个计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi;

我想每60分钟发送一封电子邮件.我需要一个计时器标签来指示下一次发送的剩余时间.我尝试过Backgorundworker这样做,但是我做不到.你能帮我吗?  

I want to send email every 60 mins. I need a timer label for indicating remaining time to the next sending. I tried do it by Backgorundworker, but I couldn't. Can you help me please?  

我的问题是计时器标签无法显示剩余时间

my problem is that timer label doesn't work to show remained time 

对不起,我的英语

推荐答案

使用Threading名称空间中的Timer类.在此处检查更多信息: http://msdn.microsoft.com/en-us/library/2x96zfy7.aspx

use Timer class from a Threading namespace. Check for more info here: http://msdn.microsoft.com/en-us/library/2x96zfy7.aspx

要记住:看一下这个例子:

To remember: take a look at this example:

Timer stateTimer = new Timer(Yout method, autoEvent, 1000, 250);

1.参数是您要调用的方法(计时器触发时将执行的代码);

1. argument is the method you want to call (the code that will be executed when timer will trigger);

2.包含要由回调方法使用的信息的对象,如果您没有将其设置为 .

2. object containing information to be used by the callback method, if you dont have any set it to null.

3.计时器第一次触发时的时间(以毫秒为单位)(如果在应用程序运行时从0开始执行).

3. the amount of time (in ms), when timer will tirgger for the 1st time (if 0 will start executing when application runs).

3.两次调用之间的时间(以毫秒为单位)(如果设置为3600000(3,6M),它将每小时增加一次).

3. the amout of time (in ms), between invocations (if set to 3600000 (3,6M) it will rise every hour).


这篇关于我想在后台有一个计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆