Environment.TickCount Environment.TickCount Environment.TickCount Environment.TickCount Property

定義

システム起動後のミリ秒単位の経過時間を取得します。Gets the number of milliseconds elapsed since the system started.

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

プロパティ値

コンピューターが最後に起動してからの経過時間をミリ秒単位で保持している 32 ビット符号付き整数。A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started.

次の例は、正の値によって返される値の範囲を取得する方法を示します、TickCountプロパティ。The following example demonstrates how to retrieve the positive range of values returned by the TickCount property. TickCountプロパティのサイクル間Int32.MinValue、負の数値であるとInt32.MaxValue49.8 日に 1 回です。The TickCount property cycles between Int32.MinValue, which is a negative number, and Int32.MaxValue once every 49.8 days. このコード サンプルは、0 は負でない数値を生成する、符号ビットを削除します。 およびMaxValue24.9 日に 1 回です。This code sample removes the sign bit to yield a nonnegative number that cycles between zero and MaxValue once every 24.9 days.

// 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 the following results:

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 the following results:

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.

Imports System

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

      Console.WriteLine("TickCount: {0}", result)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'TickCount: 101931139
'

注釈

このプロパティの値は、システム タイマーから派生され、32 ビット符号付き整数として格納されます。The value of this property is derived from the system timer and is stored as a 32-bit signed integer. システム タイマーの解像度から派生されるため、注意してください。、TickCountプロパティは通常 10 ~ 16 ミリ秒の範囲内にあるシステム タイマーの解像度に制限されます。Note that, because it is derived from the system timer, the resolution of the TickCount property is limited to the resolution of the system timer, which is typically in the range of 10 to 16 milliseconds.

重要

の値、TickCount継続的に、システムが実行されている場合、プロパティの値が 32 ビット符号付き整数では、 TickCount 0 ~ 1 ずつ増分されますInt32.MaxValue続けたに移動し、 Int32.MinValue、負の数値であります。中に 0 にし、インクリメントします。Because the value of the TickCount property value is a 32-bit signed integer, if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days, then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days. この問題を回避するには、Windows を呼び出すことによってGetTickCount関数で、または呼び出すことによって、約 49.7 日後に 0 にリセット、 GetTickCount64関数。You can work around this issue by calling the Windows GetTickCount function, which resets to zero after approximately 49.7 days, or by calling the GetTickCount64 function.

TickCount 異なる、DateTime.Ticksプロパティで、1/1/0001、12時 00分 am 以降の経過時間を 100 ナノ秒間隔の数です。TickCount is different from the DateTime.Ticks property, which is the number of 100-nanosecond intervals that have elapsed since 1/1/0001, 12:00am.

使用して、DateTime.Nowプロパティを現在の日付とこのコンピューターの時刻を取得します。Use the DateTime.Now property to obtain the current local date and time on this computer.

適用対象