bladefist
bladefist

Reputation: 1082

IIS Application Pools and Multi-threading

Will the automatic recycling of the application pool in IIS kill a working thread that was called from QueueUserWorkItem in ASP.NET?

Since this happens at set intervals and I'm getting random errors it would appear, I am wondering if these two are running into each other?

If so, how do I run an asynch task and not get killed by a recycle?

Upvotes: 0

Views: 2794

Answers (2)

Samuel Neff
Samuel Neff

Reputation: 74899

When ASP.NET recycles, any long-running tasks within the ASP.NET process will be stopped. If you need to run background tasks then create a companion windows service to host these separate tasks.

Upvotes: 1

Rahul Soni
Rahul Soni

Reputation: 4968

It depends on what kind of recycling settings you have set on the application pool. Assuming you have set recycling at a specific time [or any other condition for that matter!]... at that time a new Worker Process will be spawned, and the existing worker process will have 90 seconds to do what it was supposed to do. After that 90 seconds, whatever is present in the process would be gone.

You said it happens at set intervals. Have you set time based recycle in IIS?

Upvotes: 0

Related Questions