If I start a thread in the Application_Startup event of my web application in ASP .NET and it contains an infinite loop doing some background work using sleep methods too, will it continue running forever, assuming no exceptions occur?
Asked
Active
Viewed 679 times
2 Answers
1
.No, because IIS may shutdown your AppDomain if no request comes in for a period of time.
In shared hosting environments you can not change the appdomain settings but you have access to server it can be done by changing the default time.

Jahan Zinedine
- 14,616
- 5
- 46
- 70
-
... but i would like to add, that if you have control over the settings, it continues forever (or the settings you make) – Jan 12 '12 at 09:30
1
Short answer: Yes
I have the same in my Application to do some cleanup work.
EDIT: But Jani is also right: If the App is shut down the thread also stops, but if you have requests to keep the App alive (or configure the App under IIS/Mono that way - see HERE) it will run.

Community
- 1
- 1

Christoph Fink
- 22,727
- 9
- 68
- 113