Environment.TickCount Property
Gets the number of milliseconds elapsed since the system started.
[Visual Basic] Public Shared ReadOnly Property TickCount As Integer [C#] public static int TickCount {get;} [C++] public: __property static int get_TickCount(); [JScript] public static function get TickCount() : int;
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
The value of this property is derived from the system timer and is stored as a 32-bit signed integer. Therefore, the elapsed time will wrap around to zero if the system is run continuously for 24.9 days.
The resolution of the TickCount property cannot be less than 500 milliseconds.
The TickCount property handles an overflow condition by resetting its value to zero. The minimum value returned by TickCount is 0.
TickCount is different from the 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 on this computer.
Example
[Visual Basic] ' Sample for the Environment.TickCount property Imports System Class Sample Public Shared Sub Main() Console.WriteLine() Console.WriteLine("TickCount: {0}", Environment.TickCount) End Sub 'Main End Class 'Sample ' 'This example produces the following results: ' 'TickCount: 17995355 ' [C#] // Sample for the Environment.TickCount property using System; class Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("TickCount: {0}", Environment.TickCount); } } /* This example produces the following results: TickCount: 17995355 */ [C++] // Sample for the Environment::TickCount property #using <mscorlib.dll> using namespace System; int main() { Console::WriteLine(); Console::WriteLine(S"TickCount: {0}", __box(Environment::TickCount)); } /* This example produces the following results: TickCount: 17995355 */
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard