IIS会阻止这个帖子吗?

时间:2014-08-06 18:48:42

标签: c# asp.net multithreading iis

你好我是一个长期运行的服务类,它运行得很顺利,但它的线程一直暂停,除了每天必须检查我的asp.net网站的一些数据。它是asp.net网站中的WCF文件。该类继承自此接口:

[ServiceContract]
public interface IService
{
    [OperationContract]
    void DoWork();
}. 

这是用于创建类运行的线程的代码:

//Initialize the thread
Thread = new Thread(new ThreadStart(threadDoSomething));
//The thread is a background thread; it is a long running service
Thread.IsBackground = true;
//This Thread does not need much CPU attention so it is not a high priority
Thread.Priority = ThreadPriority.Lowest;
//Run the tread
Thread.Start(this);

我听说IIS会偶尔停止长时间运行的进程以节省内存,是否会停止此过程?

1 个答案:

答案 0 :(得分:0)

是的,当一段时间内没有收到任何活动时,IIS将回收ApplicationPools(可以配置)。

避免这种情况的一个简单方法就是在线程浏览Web应用程序中的页面以避免它,但最终有时会在很长一段时间后回收它。

<强>更新

嗯......如果您的应用是Windows服务,那么IIS与您的线程无关......