开发者

How to avoid a manually started thread from dying?

I have a process on a system that runs on IIS, it takes hours to finish so it runs on a thread.

The problem is that this thread is dropped after some time because the IIS process timeout (no activity). This thread can't stop i开发者_StackOverflow社区n the middle.

How can I prevent this timeout if the thread is running?


In the settings of the Application Pool in IIS you could configure it to not recycle the AppDomain after a certain period of inactivity. Notice however that using long running tasks in IIS is bad idea and this setting might not be 100% reliable. For example if your server starts running low on memory or high CPU usage IIS could still recycle it. IIRC this threshold could also be configured.

The best way would be to externalize those long running tasks as a separate Windows Service.

And if you cannot do any of those previous things and you are absolutely desperate the last thing you could try in your total despair is to auto-ping the web application from this background thread by sending HTTP requests at regular intervals to avoid it from dying. But once again that should really be the last thing you should attempt.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜