System.Threading.Timer
是一个简单、 轻型计时器,它使用回调方法,并由线程池线程提供服务。
//定义,写成全局变量,防止资源回收
System.Threading.Timer t1 = new System.Threading.Timer(Auto);
//要执行的函数
static void Auto(object o)
{
}
//开始(启动时间,间隔)
t1.Change(0, 1000);
//暂停
t1.Change(-1, -1);
//销毁(使用完要注意销毁)
t1.Dispose();