Clock.TickCount 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컴퓨터의 시스템 타이머에서 밀리초 수를 가져옵니다.
public:
property int TickCount { int get(); };
public int TickCount { get; }
member this.TickCount : int
Public ReadOnly Property TickCount As Integer
속성 값
Integer 컴퓨터의 시스템 타이머에서 밀리초 수를 포함하는 단위입니다.
예제
다음 예제에서는 컴퓨터의 시스템 시간이 실행되는 동안 변경되더라도 이 속성을 사용하여 My.Computer.Clock.TickCount 지정된 시간(초)동안 루프에서 작업을 실행합니다.
Public Sub LoopTask(ByVal secondsToRun As Integer)
Dim startTicks As Integer = My.Computer.Clock.TickCount
Do While IsTimeUp(startTicks, secondsToRun)
' Code to run for at least secondsToRun seconds goes here.
Loop
End Sub
Private Function IsTimeUp(
ByVal startTicks As Integer,
ByVal seconds As Integer
) As Boolean
' This function throws an overflow exception if the
' tick count difference is greater than 2,147,483,647,
' about 24 days for My.Computer.Clock.TickCount.
' Use UInteger to simplify the code for roll over.
Dim uStart As UInteger =
CUInt(CLng(startTicks) - Integer.MinValue)
Dim uCurrent As UInteger =
CUInt(CLng(My.Computer.Clock.TickCount) - Integer.MinValue)
' Calculate the tick count difference.
Dim tickCountDifference As UInteger
If uStart <= uCurrent Then
tickCountDifference = uCurrent - uStart
Else
' Tick count rolled over.
tickCountDifference = UInteger.MaxValue - (uStart - uCurrent)
End If
' Convert seconds to milliseconds and compare.
Return CInt(tickCountDifference) < (seconds * 1000)
End Function
설명
이 속성은 TickCount 컴퓨터가 활성 상태일 때 실행되는 컴퓨터의 시스템 타이머에 대한 액세스를 제공합니다. 타이머 해상도는 500밀리초 미만입니다.
이 속성을 사용하여 애플리케이션의 동작이 실행된 시간에 따라 달라지게 하거나, 이 속성을 사용하여 컴퓨터의 시계와 무관한 이벤트에 레이블을 지정할 수 있습니다.
컴퓨터가 지속적으로 TickCount 실행되는 경우 약 24.9일 동안 0에서 최대 정수 값으로 증가합니다.
이 속성은 TickCount 운영 체제가 실행 중일 때만 증가합니다. 컴퓨터가 대기 또는 최대 절전 모드와 같은 특정 절전 모드로 전환되면 일시 중지됩니다. 이 TickCount 속성은 컴퓨터의 클록 설정과 관련이 없습니다.
이 컴퓨터에서 LocalTime 현재 로컬 날짜 및 시간을 가져오려면 속성 또는 GmtTime 속성을 사용합니다.
속성은 My.Computer.Clock.TickCount 속성과 동일한 동작을 가합니다 Environment.TickCount .
프로젝트 유형별 가용성
| 프로젝트 형식 | 사용 가능 |
|---|---|
| Windows 애플리케이션 | 예 |
| 클래스 라이브러리 | 예 |
| 콘솔 애플리케이션 | 예 |
| Windows 컨트롤 라이브러리 | 예 |
| 웹 제어 라이브러리 | 예 |
| Windows 서비스 | 예 |
| 웹 사이트 | 예 |