How to create a timer to do scheduled jobs in web application?
How to create a timer to do scheduled jobs in web application?
am 16.04.2008 22:41:46 von 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
Re: How to create a timer to do scheduled jobs in web application?
am 17.04.2008 10:46:50 von 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
"elaine" wrote in message
news:bbf6c235-e15d-49c9-8e52-c27a23bd6208@w1g2000prd.googleg roups.com...
>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
Re: How to create a timer to do scheduled jobs in web application?
am 17.04.2008 10:57:19 von 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.
--
Holger Kreissl
..NET Software Developer
http://kreissl.blogspot.com/
>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
Re: How to create a timer to do scheduled jobs in web application?
am 17.04.2008 19:05:01 von Jim in Arizona
"elaine" wrote in message
news:bbf6c235-e15d-49c9-8e52-c27a23bd6208@w1g2000prd.googleg roups.com...
>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