I have a task that I want to be run 8am daily and am considering this solution: https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/
But I'm not understanding the mechanics of how it works.
Say user X visits the site on Friday at 4pm and then closes his browser and turns his computer off. Will the cache expiration still fire on Sat开发者_如何学Curday at 8am? If no users visit the site, will my process still fire every day?
Basically, my question boils down to, is this method reliable? Or is it dependent on users visiting the site?
ASP.NET Application When hosted (started) on IIS fires few Events, of Which Application_Start is one of the foremost. Setting a Background task then keeps running untill the Application is stopped/unloaded from IIS, or IIS service itself is stopped. IIS is a host process for all ASP.NET Websites.
Since the Cache is maintained on the Web Server, it has nothing to do with the active user(s).
This is analogous to a console aplpication, where the first line of code is adding something to a cache with a timer. runs as long as your console application is up and running.
Hope this helps you!
The server side cache is different to the browser cache. Users closing their browsers won't effect Jeff's code at all. However, if your application pool shuts down (and it may if there aren't any users hitting the site) then your code won't run at all until someone browses to the site, the app pool spins up again, and then it's 8am the next day (assuming the app pool is still up).
精彩评论