[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I run a piece of code every five minutes?

Posted on 2008-09-30
3
Medium Priority
?
977 Views
Last Modified: 2012-05-05
I've been reading up on System.Timers.Timer and System.Threading.Timer, but I can't seem to make the synaptic leap between my n00bness and the answer.  Basically, I just want to run a piece of code every five minutes.  Right now it's running on a button click.  I'd rather have it just run every five minutes on its own so the user can minimize the application and only worry about it when something happens.  So, how do I make a line of code run at a timed interval?
0
Comment
Question by:mrcoulson
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
joesthebighmoe earned 2000 total points
ID: 22605119
Add a timer to the form (in components on left). Set its interval to 300,000 - (1000 is abouta  second, so 300K is about 5 minutes). Make sure it's enabled property is set to true.
Double click the timer control - takes you to the tick event. This fires everytime the interval is reached. Call the code you want to code.

Also, investigate services.
http://www.google.com/search?sourceid=navclient&ie=UTF-8&rlz=1T5GGLL_enUS264US264&q=C%23+Services
0
 
LVL 7

Expert Comment

by:joesthebighmoe
ID: 22605123
I meant "Call the code you want to run."
0
 

Author Comment

by:mrcoulson
ID: 22606261
Easiest 500 points you'll earn all day?  Maybe!  Thanks a ton!  Now my app is complete.

My next version will run as a service.  I'm a new developer, so I'm taking baby steps.  Nonetheless, this thing would be better for the user if it were a service.

Jeremy
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

830 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