日期:2014-05-19  浏览次数:20486 次

定时更新!!!!!!!!!!!!!!!!!!!
各位好,请问各位用asp.net做过定时更新程序,就是在用户没有访问网站的情况下也可以更新数据,更新的时间自行设定,请大家发表自已的看法

------解决方案--------------------
不访问网站如何更新啊。除非单独一个应用程序去处理。
------解决方案--------------------
不訪問網站應該是不能更新的,除非你自己做了一個服務,否則你怎麼知道用戶需要更新什么数据到服务器
------解决方案--------------------
global.asax 里面写
private static Timer timerChangeExpired = new Timer();

protected void Application_Start(object sender, EventArgs e)
{

// 12 小时触发一次
timerChangeExpired.Elapsed += new ElapsedEventHandler(timerChangeExpired_Elapsed);
timerChangeExpired.Interval = 12 * 60 * 60 * 1000 ;


timerChangeExpired.Enabled = true;

GC.KeepAlive(timerChangeExpired);
}


void timerChangeExpired_Elapsed(object sender, ElapsedEventArgs e)
{
//自动过期
try
{
//定时更新的代码
}catch(Exception ee)
{

}
}


------解决方案--------------------
写一个系统开机任务,加上定时器,不用启动web服务也能更新数据!
继承System.ServiceProcess.ServiceBase就可以了~~至于什么更新方式,看你想怎么做了!