定时器的具体实现方法?

dongguacha 2005-11-03 07:01:27
比如要在某日某时某份启动某事件,怎样才知道“时间到”呢?
...全文
195 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wpasp 2005-11-04
  • 打赏
  • 举报
回复
试着使用API来完成你的工作??
虽然Timer占资源,但也没办法呀。
sunxia100 2005-11-04
  • 打赏
  • 举报
回复
好像用Timer方便一些,其他的什么办法,本质都是Timer,而且CPU那么快,Timer每秒一次都不会有太大影响的。建议用Timer。
我能想到的还可以用操作系统的计划管理,具体怎么做也的查一下,不过觉得不如Timer方便,得不偿失
dongguacha 2005-11-04
  • 打赏
  • 举报
回复
楼上的方法要利用timer轮询,这样做很浪费资源,能不能有别的方法
qxjboy 2005-11-03
  • 打赏
  • 举报
回复
//定时周期的检查是否到了提醒的时间
private void timer1_Click(object sender,System.EventArgs e)
{
if (DataTime.Now > dtDes)
{
timer1.Enabled=false;
this.Show();
this.Activate();
}
}
qxjboy 2005-11-03
  • 打赏
  • 举报
回复
//定义用户设定的提醒事件
private System.DataTime dtDes;
//确定提醒的时间,然后隐藏该工具
private void btn_OK_Click(object sender,System.EventArgs e)
{
dtDes=new DateTime(
DateTime.Today.Year,
DateTime.Today.Month,
DateTime.Today.Day,
(int) ndHour.Value;
(int) ndMinute.Value
0,0);
timer1.Enabled=true;
this.Hide();

}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧