Solved

Schedualed Tasks (Asp.net)

Posted on 2006-06-20
7
232 Views
Last Modified: 2006-11-18
I have a file that i need to re-create every 30 mins.  The process involed in this update takes about 30 second so this means it would be to long to do when a normal user is visiting hte page.  I thought about setting a time and if time > 30, then update, however it does take some time and the person would just shut the browser.

I could easily create a page to do this, however i kind of dont want to be clicking a page every 30mins for the rest of my life.  Is there any way to do this?


Also, i need to be able to update this "thing that creates the file" constantly during the development of it, so i need a eays way to restart/refresh it with the new code.

Thanks.

0
Comment
Question by:UnexplainedWays
  • 4
  • 2
7 Comments
 
LVL 15

Expert Comment

by:deepaknet
ID: 16941755
In the server, you can have a VBScript file that is configured with Windows Scheduled Task. Now, from this VBScript, you can use XmlHttpRequest to send a request to the webserver.
0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16941791
I was after something on the server side only, because when my computer is off, then this file wont be update.
0
 
LVL 2

Accepted Solution

by:
T3Logic earned 500 total points
ID: 16941883
What you can do is create the page that you want to run every 30 minutes.

Create a file such as time.txt that will store the time last run.

On your index page or wherever you want to set this up write a procedure that will run asynchronously.

For instance here is the c# code, not sure what language you want it it.
---------------------------
        System.Threading.ThreadStart entry = new System.Threading.ThreadStart();
        System.Threading.Thread thrd =  new System.Threading.Thread(function that runs file);
        thrd.Start();
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16941953
Sow how do i turn that threading into a 30 min timer?
0
 
LVL 2

Expert Comment

by:T3Logic
ID: 16942165
Since this is asp.net,

What language are you using?

I presume your home page is index.aspx

I am not sure if you are using code behind, but guessing that you are.

In the onload portion of the page,

create a date variable to hold the current time.
read the time from time.txt.
Compare the 2.
If difference is greater than 30 minutes
run the desired file in the background

This way the user does not need to wait for the other file to finish.  Even if they close there browser it will still run till finished.
0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16943135
Well, this "file" is getting the weather from a web service.

So when someone comes to my site, they will be reading in the old xml file and the temps will be all wrong (thats if no one has come to my site for a while) while the new one is being created.

I wouldn't use the index page, i would use the master page so no matter what page they are viewing it will run.



And yes it's asp.net and it's in C# and yes i always use a code behind file.
0
 
LVL 12

Author Comment

by:UnexplainedWays
ID: 16962625
I think you might be onto something with this threading, i could have a start/stop page.  Basically i go to this page and start the thread, this thread then just keeps running and sleeps for 30 mins at a time and keeps going untill i stop it with the start/stop page (i'll have a text file with the status of the thread, so it will read it @ the 30 mins and kill itself)

This should work :D (last thing i wanted was a thread that i couldnt stop running on the server lol)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question