Solved

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

Posted on 2008-09-30
3
972 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
[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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
joesthebighmoe earned 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

718 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