Upraviť

Zdieľať cez


Environment.TickCount Property

Definition

Gets the number of milliseconds elapsed since the system started.

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

Property Value

A 32-bit signed integer containing the amount of time in milliseconds that has passed since the last time the computer was started.

Remarks

This property returns the truncated result of TickCount64. For version differences and information about update frequency, see the TickCount64 remarks.

Important

Because the value of the TickCount property value is a 32-bit signed integer, if the system runs continuously, TickCount increments from zero to Int32.MaxValue for approximately 24.9 days, then jumps to Int32.MinValue, which is a negative number, then increments back to zero during the next 24.9 days. You can work around this issue by casting the result of TickCount to uint. This works because int and uint are a two's complement representation. This workaround is valid on all platforms.

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.

Use the DateTime.Now property to obtain the current local date and time.

Applies to

See also