Solved

Schedualed Tasks (Asp.net)

Posted on 2006-06-20
7
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

696 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