views:

215

answers:

2

We're running a web service as a web site project. Clients make requests which return after a few seconds, but which spawn a thread that should run for hours. The thread makes web requests and writes to a database, and is throttled with Thread.Sleep calls.

After running for about 20 minutes with several threads running, all the threads receive a ThreadAbortException at the same time. Thread.resetAbort doesn't help. The exception can occur during a SQL call, during a web request or during a Thread.Sleep.

I thought the problem might be the httpRuntime attribute executionTimeout in web.config, but that didn't solve the issue.

Any other ideas what might be killing off all our threads?

+2  A: 

I would guess that the web application owns the thread, and the application shuts down after a period of time.

If I were architecting something like this, I would write a web services which takes yourp your clients requests and puts them in a database, then I'd write a windows service that polls that database for client requests and spawns the threads which do whatever it is you need (makes web requests and write to a database). It sounds like your writing some sort of processor engine, and I don't think an asp.net app is a good place to host that kind of thing.

Jeremy
Agreed. I don't control the architecture on this project, but these kinds of problems are good fuel for that argument.
Jeremy Stein
+1  A: 

The application pool in IIS has an idle time-out. It needed to be turned off.

(Administrative Tools > IIS. Right-click the application pool > properties. Performance tab.)

Jeremy Stein