这里写自定义目录标题
先看一个延时函数Delay
public static bool Delay(int delayTime)
{
DateTime now = DateTime.Now;
int s;
do
{
TimeSpan spand = DateTime.Now - now;
s = spand.Milliseconds;
Application.DoEvents();//那么在循环中加入这句话,界面消息就会及时的得到更新(既不会假死);
}
while (s < delayTime);
return true;
}
这个延时函数不会造成界面的假死。
该方法可以处理当前队列的消息,比如一个循环需要执行很多次,那肯定会假死一会儿的。
此时便可使用Application.DoEvents()来处理队列的信息。
简单说下使用Application.DoEvents() 和 不使用Application.DoEvents() 的区别:
不使用Application.DoEvents():
循环耗费的时间多的话,界面会假死一会儿,然后等待循环完全结束后然后显示界面。
使用Application.DoEvents():
那么在循环中加入这句