주니봉
  • C# Delay 함수
    2015년 10월 08일 08시 24분 51초에 업로드 된 글입니다.
    작성자: 봉주니
    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)을 입력하여 사용가능하다.


    반응형
    댓글