Timer in the web application on servre site.

  • Thread starter Thread starter Vasil Buraliev
  • Start date Start date
V

Vasil Buraliev

Would you tell me please is it posible to make some code somewhere in web
application where this code will be called or started after some time?
For example.
I wanna my web applicaiton to check let's say every12 hours which day it is
on the web server than let's say if it's monday... to do somehing.

Is it possible with some technologi or somehow somewhere insite web
application?

best regards.
Vasil
 
I've seen situations where it's beneficial to do what Vasil wants to do.
For example, if you pay for a web host, and you only have access to run web
pages, but not local programs and services, then you can't go the service
route. Rather than look at it as a timer related programming challenge,
perhaps it would be better to simply flag which dates the required action
has been performed on, and simply check the status each time the page is
loaded.

I was minding my own business when Steve C. Orr [MVP, MCSD] blurted out:
 
You can do this by starting a new Thread in a static block in a class.

Here is how you do it.
1. create a static constructor in a "Manager" class (or add it in any class
you prefer) -- this guarentees that the following thread only get created
once (when you first reference this class.)
2. In that static constructor create a new thread and let it do whatever you
want every 12 hours (using a loop and sleep method)
3. In your web application, refer to this class (by either instantiate the
Manager class or just reference it)


Jianjun
 
This sounds very interesting. I will try this. Thanks for your idea Jianjun,
and thank you all you guys for your reply.

regards.
Vasil
 
Back
Top