Timer 속성
업데이트: 2007년 11월
자정 이후 경과된 초 수를 나타내는 Double 값을 반환합니다.
ReadOnly Public Property Timer() As Double
설명
Timer 속성은 가장 최근의 자정 이후 경과된 초와 밀리초를 모두 반환합니다. 반환 값의 정수 부분은 초를 나타내고 소수 부분은 밀리 초를 나타냅니다.
예제
다음 예제에서는 Timer 속성을 사용하여 응용 프로그램을 일시 중지합니다. 일시 중지 상태에서 다른 작업을 처리할 수 있습니다.
Public Sub waitFiveSeconds()
If TimeOfDay >= #11:59:55 PM# Then
MsgBox("The current time is within 5 seconds of midnight" & _
vbCrLf & "The timer returns to 0.0 at midnight")
Return
End If
Dim start, finish, totalTime As Double
If (MsgBox("Press Yes to pause for 5 seconds", MsgBoxStyle.YesNo)) _
= MsgBoxResult.Yes Then
start = Microsoft.VisualBasic.DateAndTime.Timer
' Set end time for 5-second duration.
finish = start + 5.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
' Do other processing while waiting for 5 seconds to elapse.
Loop
totalTime = Microsoft.VisualBasic.DateAndTime.Timer - start
MsgBox("Paused for " & totalTime & " seconds")
End If
End Sub
Timer는 System.Threading, System.Timers 및 System.Windows.Forms 네임스페이스에도 정의된 클래스이기 때문에 Microsoft.VisualBasic 네임스페이스를 사용하여 Timer 속성을 한정해야 합니다.
요구 사항
네임스페이스:Microsoft.VisualBasic
**모듈:**DateAndTime
**어셈블리:**Visual Basic 런타임 라이브러리(Microsoft.VisualBasic.dll)
Timer는 클래스의 멤버가 아니라 모듈의 멤버이므로 Timer에 액세스하기 위한 개체를 만들 필요가 없습니다.