Environment.TickCount 속성

정의

시스템 시작 이후 경과 시간(밀리초)을 가져옵니다.

public:
 static property int TickCount { int get(); };
public static int TickCount { get; }
static member TickCount : int
Public Shared ReadOnly Property TickCount As Integer

속성 값

컴퓨터가 마지막으로 시작된 이후 경과된 시간(밀리초)을 포함하는 부호 있는 32비트 정수입니다.

예제

다음 예제에서는 속성에서 반환된 값의 양수 범위를 검색하는 방법을 보여 줍니다 TickCount . 속성은 TickCount 음수 Int32.MaxValue 인 와 49.8일마다 한 번 사이Int32.MinValue를 순환합니다. 이 코드 샘플은 부호 비트를 제거하여 24.9일마다 0 MaxValue ~1회 순환하는 무수 값을 생성합니다.

// Sample for the Environment::TickCount property
// TickCount cycles between Int32::MinValue, which is a negative 
// number, and Int32::MaxValue once every 49.8 days. This sample
// removes the sign bit to yield a nonnegative number that cycles 
// between zero and Int32::MaxValue once every 24.9 days.
using namespace System;
int main()
{
   int result = Environment::TickCount & Int32::MaxValue;
   Console::WriteLine( "TickCount: {0}", result );
}

/*
This example produces an output similar to the following:

TickCount: 101931139
*/
// Sample for the Environment.TickCount property.

// TickCount cycles between Int32.MinValue, which is a negative
// number, and Int32.MaxValue once every 49.8 days. This sample
// removes the sign bit to yield a nonnegative number that cycles
// between zero and Int32.MaxValue once every 24.9 days.

using System;

class Sample
{
    public static void Main()
    {
    int result = Environment.TickCount & Int32.MaxValue;
    Console.WriteLine("TickCount: {0}", result);
    }
}
/*
This example produces an output similar to the following:

TickCount: 101931139
*/
// Sample for the Environment.TickCount property.

// TickCount cycles between Int32.MinValue, which is a negative
// number, and Int32.MaxValue once every 49.8 days. This sample
// removes the sign bit to yield a nonnegative number that cycles
// between zero and Int32.MaxValue once every 24.9 days.

open System

let result = Environment.TickCount &&& Int32.MaxValue
printfn $"TickCount: {result}"

// This example produces an output similar to the following:
//     TickCount: 101931139

' Sample for the Environment.TickCount property.
' TickCount cycles between Int32.MinValue, which is a negative 
' number, and Int32.MaxValue once every 49.8 days. This sample
' removes the sign bit to yield a nonnegative number that cycles 
' between zero and Int32.MaxValue once every 24.9 days.

Class Sample
   Public Shared Sub Main()
      Dim result As Integer = Environment.TickCount And Int32.MaxValue

      Console.WriteLine("TickCount: {0}", result)
   End Sub
End Class
'
'This example produces an output similar to the following:
'
'TickCount: 101931139
'

설명

이 속성의 값은 시스템 타이머에서 파생되며 32비트 부속 정수로 저장됩니다. 시스템 타이머에서 파생되므로 속성의 TickCount 해상도는 일반적으로 10~16밀리초 범위인 시스템 타이머의 해상도로 제한됩니다.

중요

속성 값의 TickCount 값은 32비트 부호 있는 정수이므로 시스템이 지속적으로 TickCount 실행되는 경우 는 약 24.9일 동안 0 Int32.MaxValue 에서 증분한 다음 음수인 로 이동 Int32.MinValue한 다음, 다음 24.9일 동안 다시 0으로 증가합니다. 약 49.7일 후에 0으로 다시 설정되는 Windows GetTickCount 함수를 호출하거나 GetTickCount64 함수를 호출하여 이 문제를 해결할 수 있습니다.

TickCount 는 0001년 1월 1일 오전 12시 이후 경과된 100나노초 간격의 수인 속성과 다릅니다 DateTime.Ticks .

사용 된 DateTime.Now 이 컴퓨터에서 현재 로컬 날짜 및 시간을 가져오려면 속성입니다.

적용 대상