Link to home
Start Free TrialLog in
Avatar of RTSol
RTSol

asked on

Program that runs once a week

Hi,

I need to write a program for a web site that allways runs once a day. My idea is to use a snipped according t the supplied code below. I know this code is stupid and will block the site - but an idea along those lines.  My question is - is this the best approach and how do I make sure that this code always is alive. What if I want this task to start running before any visits to the site has occured - how is that done? If I want the task to allways run at a specific time each day - how is that done? The site is hosted at an ISP and my access to the web server is very limited.

Best regards
RTSol
protected void Page_Load(object sender, EventArgs e)
    {
        //do other things ...
        ScheduledTask();
    }

    protected void ScheduledTask()
    {
        //Do the stuff
        Thread.Sleep(86400000); //sleep 24 hours
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of halceyon
halceyon
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Reza Rad
you can create another page for notcorrecttime view.
and in your scheduled task try to check time of day, if it is the time you want to start doing , then do anything you want , otherwise redirect to notcorrecttime page you created.
maybe you need autorefresh on your page, because page_load will called only when a user browse on your page
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RTSol
RTSol

ASKER

Thanks for your tips guys. I think the link from halceyon is what I really wants. Building a service would probably be the best but my ISP will not let me install it on the web server.