我想在预定义的时间过去后重复执行代码,并且我不想通过使用线程搞乱事情。下面的代码是一个好习惯吗?重复执行代码
Stopwatch sw = new Stopwatch(); // sw constructor
EXIT:
// Here I have my code
sw.Start();
while (sw.ElapsedMilliseconds < 100000)
{
// do nothing, just wait
}
System.Media.SystemSounds.Beep.Play(); // for test
sw.Stop();
goto EXIT;
的坏很好的例子做法;) – sll 2012-04-06 08:54:58