1.Global.asax
//定义定时器
//300000表示5分钟的意思
System.Timers.Timer myTimer = new System.Timers.Timer(300000);
//TaskAction.SetContent 表示要调用的方法
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(TaskAction.SetContent);
myTimer.Enabled = true;//激活
myTimer.AutoReset = true;//开启到点自动执行方法
2.自定义类 想要执行的方法
public static class TaskAction
{
/// 定时器委托任务 调用的方法
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
public static void SetContent(object source, ElapsedEventArgs e)
{
#region 要定时执行的代码
。。。。。。。
#endregion
}
}