web服务线程实现定时活动(上一篇使用timer实现定时器,但发现timer会死掉,定时任务不会触发,查询文档发现timer隔段时间会被iis应用池回收)
private System.Threading.Thread t;
void Application_Start(object sender, EventArgs e)
{
t = new System.Threading.Thread(NewThreadStar);
t.Start();
}
/// <summary>
/// 线程调用的方法
/// </summary>
private void NewThreadStar()
{
//要执行的目标方法
NotamBufferWebService notma = new NotamBufferWebService();
notma.BuildMemory();
//当前线程挂起指定时间
System.Threading.Thread.Sleep(600000);
//递归调用实现循环
NewThreadStar();
}