1、首先引入命名空间
<%@ Import Namespace ="System.IO" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Reflection" %>
...
2.创建定时更新的方法
static void UpdateClubs(object o)
{
//代码
}
</script>
3、定时调用该方法
void Application_Start(object sender, EventArgs e)
{
//在应用程序启动时运行的代码
TimerTest s = new TimerTest();
System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(UpdateClubs);
System.Threading.Timer timer = new System.Threading.Timer(timerDelegate, s, 10, 1000 * 60 * 5);5分钟执行一次UpdateClubs方法
s.tmr = timer;
}
public class TimerTest
{
public int counter = 0;
public Timer tmr;
}
转载于:https://www.cnblogs.com/extensivewang/archive/2009/09/22/1571945.html