asp.net开启线程实时巡查数据库的问题
我想在Global中开一个线程,让它查数据库。我是在Application_Start中开启线程的并调用查询数据库的方法,代码如下
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(SelectConnectionSql));
Application["IdeoClass_Thread"] = th;
th.Start();
}
//查数据库方法
public void SelectConnectionSql()
{
。。。。。。。。。。。。。。
}
但是发现如果长时间无人访问网站的话或其他未知原因,执行不到查数据库的方法!
我想要实现线程(24小时)实时查询数据库。请问怎么来实现!
跟IIS设置有什么关系吗?请高手指点