Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-09-30
3
Medium Priority
?
976 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 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

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!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

609 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