c# 不用Timer控件

不用timer控件如何实现定时的功能
2025-03-12 01:38:19
推荐回答(4个)
回答1:

实例化timer控件,然后给个委托过去就成了

代码如下:
System.Timers.Timer crazycoderTimer= new System.Timers.Timer(30 * 60 * 1000);//定义为30分钟执行一次
crazycoderTimer.Elapsed += new System.Timers.ElapsedEventHandler(crazycoderTimer_Tick);

private void crazycoderTimer_Tick(object sender, System.Timers.ElapsedEventArgs e)
{
//定时执行代码 比如定时访问http://www.crazycoder.cn/

}

回答2:

线程 Timer类和Timer类(不同命名空间,总共有三个Timer)

回答3:

用线程。。。。
网上有教程,其实很简单。。。。

回答4:

可以用线程实现