Timers in global.asax

M

Mubi

I am using VS2003 and developing web services. We also need a timed
activity to be performed on the server. If i drag a timer and place it
on global.asax, add interval and timer handler. it doesnot work. Is
there anyone with the answer. How could i achieve this functionality.
 
P

Patrice

A web application is IMO not well suited for this kind of task. Basically it
runs when a user hit the server.

My personal preference would be by far to create a separate application to
do that. As most often it's best to tell also *waht* you are trying to do.
For example if this is a DB related task and you are using SQL Server,
creating a SQL Server scheduled job would be likely much simpler...
 
A

Aidy

It's possible, but not recommended as you can't guarantee the web site is
loaded and running, so if left idle your process will just die. Best bet is
to write a Windows Service to do the job.

What you can do is store the timer object in the Application, or create a
class that uses a timer object (or just threading solutions like the
AutoResetEvent) to do the work and store that in the Application. If it's
critical your code runs on time then this solution won't work.
 
P

Phil Johnson

Mubi,

I recently implemented an application that needed to refresh data from a
feed every minute and I was going to try to use a timer on it.

I had the same problem as you, so what I did was, in the begin request even
handler in the global asax, I updated my data from the feed then put the time
into an application state variable. on every begin request, if the current
time was more than a minute on from the one stored in the application state
variable then it updated the data from the feed and also updated the
application state variable

This approach is working for my situation. You probably need to define if
you need your timed event to run twenty four seven, or is it only required
when people are accessing the service?

--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top