How to execute the loop for specific time

后端 未结 7 1051
心在旅途
心在旅途 2020-12-05 13:37

How can i execute the a particluar loop for specified time

Timeinsecond = 600

int time = 0;
while (Timeinsecond > time)
{
   // do something here
}
         


        
7条回答
  •  忘掉有多难
    2020-12-05 14:09

    Instead of such an expensive operation I'd recommend this: It's nasty but it's better to sit than running for doing nothing heating the cpu unnecesarily, the question is may be academic.

    using System.Threading;
    
    Thread.Sleep(600000);
    

提交回复
热议问题