转自https://www.cnblogs.com/masonlu/p/11237382.html
用Thread.Sleep()函数,但是这个函数在等待过程中会操作界面的卡死,那么,如何能保证既不卡死又能达到等待的功能呢?其实也很简单,用下面的一段代码代替Thread.Sleep()函数即可:
#region 毫秒延时 界面不会卡死
public static void Delay(int mm)
{
DateTime current = DateTime.Now;
while (current.AddMilliseconds(mm) > DateTime.Now)
{
Application.DoEvents();
}
return;
}
#endregion