I have an IIS 6.0-based C#/ASP.NET web site with a SQL server backend. I want to generate some computationally expensive reports (summaries, search engine indexes, etc...) in idle CPU time. I need the reports to be generated from WITHIN the IIS App Pool so it knows the proper configuration settings and (harder to fix) avoids the nightmarish security restrictions I've been placed under.
Can I start threads inside the AppPool's process that won't tie up the CPU, so it can continue serving requests unfettered? If so, how? What code and libraries?
I imagine it involves ThreadPool and thread priorities, but I couldn't find good coverage of low-pri threads and their interaction with the IIS web server and App pool.
[EDIT] http://msdn.microsoft.com/en-us/magazine/cc163854.aspx#S7 discusses using a Timer for this but doesn't directly state that the .NET framework will insure that the Timer thread is low-priority. This might be a solution, but is that assured?
[EDIT] This guy talks about important exception-related issues: http://flimflan.com/blog/SafelyRunningBackgroundThreadsInASPNET20.aspx
[EDIT] Interestingly, Stack Overflow itself seems to use IIS background threads for my purpose: http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/... in the comments, everyone says their (no longer used) technique sucks, but this one in the comments makes sense to me...