If you're doing ASP.NET, you'll definitely use IIS
If you want to add a scheduled task to your ASP.net application, you must use a thread to do the scheduled calculations non-stop
Then let's say we add Quartz.NET framework to our ASP.Net application, and the configuration and so on are OK.
This site has very few visits, and now only a few people use it when they are at work, but the next day I came over and saw that the threads and calculation tasks of the background scheduling were stopped, and if you grab Application_End event, you will find that this event was actually called.
Then there must be something wrong with IIS's application pool recycling mechanism. Because the default setting of IIS is that if the application pool of a site is not accessed or requested for a period of time, IIS will automatically reclaim the program pool and kill the process. The threads in that process will definitely not survive.
However, we can set the application pool parameters so that they are not simply automatically recycled (some situations are unavoidable, such as hot-deployed sites, excessive number of errors, etc.)
Find the program pool used by this site in IIS and click "Advanced settings..."
Change the following settings in the list that opens:
Recovery - Fixed time interval (minutes) changed to 0
- Virtual/dedicated memory limit (KB) changed to 0
Process model - Idle timeout (minutes) is changed to 0
In this way, the program pool will not be automatically recycled, and some simple computing threads in the background will work normally |