Board index » Visual Studio » performing action repeatedly after a certain interval

performing action repeatedly after a certain interval

Visual Studio305
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


-
 

Re:performing action repeatedly after a certain interval

Why not user the timer control?



"Sameh Ahmed" <essoplus@hotmail.com>wrote in message

Quote
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













-

Re:performing action repeatedly after a certain interval

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/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfSystemWindowsFormsTimerClassTopic.asp



System.Timers.Timer:

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfsystemtimerstimerclasstopic.asp



hope that helps..

Imran.



"Sameh Ahmed" <essoplus@hotmail.com>wrote in message

Quote
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









-

Re:performing action repeatedly after a certain interval

thanks people

that was more then enough:)



"Imran Koradia" <nospam@microsoft.com>wrote in message

Quote
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/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfSystemWindowsFormsTimerClassTopic.asp



System.Timers.Timer:



http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfsystemtimerstimerclasstopic.asp



hope that helps..

Imran.



"Sameh Ahmed" <essoplus@hotmail.com>wrote in message

news:e9G%23c%23gsEHA.2980@TK2MSFTNGP10.phx.gbl...

>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

>

>









-