Running a Timer in a Web App
Hey there
I need to create a timer that fires an event every hour to check a value in my database. I'm not 100% sure of the best way to do this, or where to put the code so it does not interfere with the app in anyway (performance, people browsing the site, etc.) Should I make a new thread and run the code in there? Or maybe a web service can help? I do not have access to the live server, so I cannot make a windows sheduled task, windows service or something else along those lines.
I'm using VB.Net and ASP.Net, with a SQL server db running on a windows platform.
help please !
patch
Re: Running a Timer in a Web App
I you have to run the event from your web application there is a timer component in the toolbox under components.
If you look it up under the index as system.timers.timer, you can check out all its properties and methods, but you would essentially set the interval at which the elapsed event should run and then on page_load start the timer, so every hour the elapsed event would fire and you could do your database check.
Though the page would have to be up the whole time.
There might be a better solution for this, but I am quite new to all this myself.
Re: Running a Timer in a Web App
Yeh i've got all the code for it, thats no problem, just not sure where the best place to put it is. I wont put it in a form, as the form will not always be up. I do have a place in my one instance of a class, as that is always running, but i'm just not sure if that would be the best regarding performance, threading issues, etc.
Any other ideas ?