tags:

views:

22

answers:

2

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?

A: 

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?

Rahul Soni
Yea. Every 2000 mins or so to prevent this from happening often. But these tasks are apart of a service, and are long running.
bladefist
+1  A: 

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.

Sam
I think unfortunately you are correct. Thanks
bladefist