Solved

Schedualed Tasks (Asp.net)

Posted on 2006-06-20
7
228 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now