performing action repeatedly after a certain interval

  • Thread starter Thread starter Sameh Ahmed
  • Start date Start date
S

Sameh Ahmed

hello there
need to create an application that checks for a condition every 5 minutes
and performs a certain action depending on whether the condition was met or
not.
what is the best way to do that?
using "system.Threading.Thread.Sleep (5000)" is the option I have in mind
now as I believe using a Do while loop will be quite resource intensive.
any ideas?
Regards
Sameh
 
Take a look at timers. There are 3 timers in the .NET framework. The ones
suitable in your case would be System.Windows.Forms.Timer
System.Timers.Timer. For the Forms timer, check your condition in the Tick
Event of the timer and for Timers timer, you can check your condition in the
Elapsed Event. Examples can be found in the MSDN documentation -

System.Windows.Forms.Timer:
http://msdn.microsoft.com/library/d...ml/frlrfSystemWindowsFormsTimerClassTopic.asp

System.Timers.Timer:
http://msdn.microsoft.com/library/d...ref/html/frlrfsystemtimerstimerclasstopic.asp

hope that helps..
Imran.
 
thanks people
that was more then enough:)

Imran Koradia said:
Take a look at timers. There are 3 timers in the .NET framework. The ones
suitable in your case would be System.Windows.Forms.Timer
System.Timers.Timer. For the Forms timer, check your condition in the Tick
Event of the timer and for Timers timer, you can check your condition in the
Elapsed Event. Examples can be found in the MSDN documentation -

System.Windows.Forms.Timer:
http://msdn.microsoft.com/library/d...ml/frlrfSystemWindowsFormsTimerClassTopic.asp
http://msdn.microsoft.com/library/d...ref/html/frlrfsystemtimerstimerclasstopic.asp

hope that helps..
Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top