Background function in asp.net
Is it possible to write a background function in a master page that triggers after a specific period of time, say 5 hours?
function开发者_Python百科()
{
execute code from the clsGeneral Class
}
Please suggest how this can be implemented.
Pre IIS 7.5 you don't. (technically you can, but it's stupid). IIS is free to terminate your app whenever he wants, and when IIS is restarted, apps are restarted "lazily" (until someone opens a page of your web app, the web app isn't started).
From IIS 7.5 onward you could using the Application Warm-Up Module (sadly the beta was removed :-) ). With it you create a Thread that waits the specified time and does something. Quite easy.
The "right" solution is normally to create a Windows Service and use Quartz. Read here for example Scheduler for ASP.NET?
精彩评论