3

I have a web service that creates a thread to process some data in the background. I've seen a "System.Threading.ThreadAbortException: Thread was being aborted" message in one of my logs where the thread was killed. I am currently under the assumption that the thread will run as long as it takes to execute the tasks that it's working on, however after googling the exeception I've seen several posts making mention of increasing the ExecutionTimeOut property of the application in the web.config file. My question is:

What is the maximum execution time of a thread executed in ASP.NET? Is this timeout unlimited or still bound by the ExecutionTimeOut property of the application?

Achilles
  • 11,165
  • 9
  • 62
  • 113
  • Another potential thing to look out for is: what happens when the response is completed? Does the entire process get thrown out? Do resources get cleaned up (such as spawned threads). If so, you would need to start the thread in some other way and then communicate work to it. – TheJacobTaylor May 10 '10 at 16:37
  • @TheJacobTaylor No, that's a good thought but a thread can continue executing after the request finishes processing. – cortijon May 10 '10 at 16:53
  • Oh we ran into this problem already,the trick is to make sure your new thread is not manipulating a reference that was retured by the web service or the reference will be destroyed during GC – Achilles May 10 '10 at 17:18
  • 1
    I found why my thread was killed. If you change the web.config file, the application restarts thus killing the threads associated with it. – Achilles May 10 '10 at 17:20
  • @MrGumbe Thanks, I wasn't sure if .NET had a fastCGI mode where things would be cleaned up automatically or if that might be a configuration option. – TheJacobTaylor May 11 '10 at 17:58

1 Answers1

3

This is a similar question.

How to know who kills my threads

You can run it as long as the pool is running. If the pool thats keep the thread is restart then its wait for all the threads to exits, but the web service to run the pages stop working at this moment, and you have problems. Also if you have setup your pool then in pool recycle if the thread is not stop after some time its kill it.

In My program one index thread it was running for more than 26 hours doing hard database work, and was on static function.

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150