티스토리 뷰

P rogramming/C # (13.05~)

C# Delay 메쏘드

Only I Can 2013. 5. 22. 09:25

/// <summary>
/// Delay 함수 MS
/// </summary>
/// <param name="MS">(단위 : MS)
///
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(1000) // 1000 = 1초


댓글
댓글쓰기 폼