How to create a timer to do scheduled jobs in web application?

E

elaine

I have a web appliacation, what i want to do is starting a timer when
"Application_Start" event handler is called. The timer is running
asyncronizely, let's say, every 24 hours, it will create a new thread
to run a certain process, after the process is done, the thread will
be killed.

So far, i have no idea how to do it. Can i instantiate a singleton
object in "Application_Start"? How to make a timer to be running
asyncronizely?

Please help,
Elaine
 
E

Eliyahu Goldin

Web applications are not good for this sort of task. Web application
response to client requests and doing something with them outside of client
requests is not what they are for.

Typically, you would either use Windows scheduler or make your own Windows
service.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
H

Holger Kreissl

What you describe should not be part of the webserver process because it
would be a bad design. You want to trigger a Process X that does something.
So use database triggers, task planer or create an own processes or windows
service that implements the Process X. Encapsulate your logic you wanted to
do in your web application into a assembly and reference it to your process.
 
J

Jim in Arizona

elaine said:
I have a web appliacation, what i want to do is starting a timer when
"Application_Start" event handler is called. The timer is running
asyncronizely, let's say, every 24 hours, it will create a new thread
to run a certain process, after the process is done, the thread will
be killed.

So far, i have no idea how to do it. Can i instantiate a singleton
object in "Application_Start"? How to make a timer to be running
asyncronizely?

Please help,
Elaine


As with the others, I have to agree that creating your own services would
probably be a good idea for this. You could have the web app start the
service using the system.serviceprocess.servicecontroller class and then
have that service take over from there with its own timer and, after the
elapsed time, shut itself down. I've created similar services like this
before and its fairly easy (in most cases I'm sure).

If you need further assistance, reply back.

HTH,
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top