Solved

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

Posted on 2008-09-30
3
967 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 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

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

20 Experts available now in Live!

Get 1:1 Help Now