المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Do something every t seconds



C# Programming
05-29-2009, 06:52 AM
Hi,

Using a thread and a while(true) is the best way? or is there any method that isn't consuming cpu on the background every iteration?


DateTime nextCheck = DateTime.Now.AddSeconds( t );

while (true)
{
if (DateTime.Now > nextCheck)
{
nextCheck.AddSeconds( t );
do the thing...
}
}