C#
C# Delay 함수
봉주니
2015. 10. 8. 08:24
using system.Threading 을 선언하고
Thread.sleep(3000)을 선언하여 3초를 줄 수 있지만 프로그램이 멈추는 문제가 발생하여
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;
}
함수를 선언하고 Delay(3000)을 입력하여 사용가능하다.
반응형