Thread.sleep 쓰면 일반적인 용도로 대기 시간 주기에는 폼이 멈춰서 불편하다.
화면이 멈추지 않고 딜레이를 줄수 있게끔 하는거.
private static DateTime Delay(int MS)
{
DateTime ThisMoment = DateTime.Now;
TimeSpan duration = new TimeSpan(0, 0, 0, 0, MS);
DateTime AfterWards = ThisMoment.Add(duration);
while (AfterWards >= ThisMoment)
{
System.Windows.Forms.Application.DoEvents();
ThisMoment = DateTime.Now;
}
return DateTime.Now;
}
0 댓글