如何执行对于特定时间的循环 [英] How to execute the loop for specific time
本文介绍了如何执行对于特定时间的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么能执行一个particluar环路指定的时间
How can i execute the a particluar loop for specified time
Timeinsecond = 600
int time = 0;
while (Timeinsecond > time)
{
// do something here
}
如何此处设置的时间varaible,如果我可以使用Timer对象的启动和停止方法是亘古不变的还给我时间(秒)
How can i set the time varaible here, if i can use the Timer object start and stop method it doesnot return me time in seconds
问候
NewDev
Regards NewDev
推荐答案
可以是以下帮助:
Stopwatch s = new Stopwatch();
s.Start();
while (s.Elapsed < TimeSpan.FromSeconds(600))
{
//
}
s.Stop();
这篇关于如何执行对于特定时间的循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文