응용 프로그램이 시작되면 Application.Idle
이벤트에 대한 처리기를 만듭니다. 또한 10 분 타이머 인 개체를 만듭니다. 이벤트 큐가 비울 때마다 Appliation.Idle
이벤트가 발생합니다. 마우스를 움직이면 이벤트가 발생합니다. 키를 누르면 이벤트가 발생합니다. Application.Idle
과 함께 Handles
키워드를 사용할 수 없습니다. Handles
은 정적 개체가 아닌 로컬 데칼링 된 개체에만 작동합니다. 사용자가 10 분 이상 걸리는 작업을 시작하면이와
Public Sub MainForm_Load(sender As Object, e As EventArgs) Handles MainForm.Load
AddHandler System.Windows.Forms.Application.Idle, AddressOf Application_Idle
' TODO: Create the 10-minute timer.
End Sub
Private Sub Application_Idle(sender As Object, e As EventArgs)
' TODO: Restart the 10-minute timer.
End Sub
' This assumes your TenMinuteTimer object has an Expire event. Do what works for you instead.
Private Sub TenMinuteTimer_Expire(sender As Object, e As EventArgs) Handles TenMinuteTimer.Expire
' TODO: Close the application safely.
End Sub
유일한 문제는, 그것은 TenMinuteTimer.Expire
후 Application.Idle
을 올릴 것이다. 이 문제가 발생할 것으로 예상되면 장기 실행 코드를 실행하기 전에 TenMinuteTimer를 비활성화하고 나중에 다시 활성화하십시오.