Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chat Room 1 43
c# LinkButton OnClientClick 2 33
Name space syntax error 12 39
Page navigation in windows phone 8.1 application not working. 5 13
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 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

10 Experts available now in Live!

Get 1:1 Help Now