private void Delay(int Millisecond) //延迟系统时间,但系统又能同时能执行其它任务;
{
DateTime current = DateTime.Now;
while (current.AddMilliseconds(Millisecond) > DateTime.Now)
{
Application.DoEvents();//转让控制权
}
return;
}
这个类我在之前的文章中也有介绍到,今天为什么把它单独提出来呢?因为这个类在写C#的程序中有很大的作用,常常在很多循环中使用它比使用直接停止线程的方法好的多。希望大家会喜欢它。
{
DateTime current = DateTime.Now;
while (current.AddMilliseconds(Millisecond) > DateTime.Now)
{
Application.DoEvents();//转让控制权
}
return;
}
这个类我在之前的文章中也有介绍到,今天为什么把它单独提出来呢?因为这个类在写C#的程序中有很大的作用,常常在很多循环中使用它比使用直接停止线程的方法好的多。希望大家会喜欢它。