Stopwatch.GetTimestamp Method

Note: This method is new in the .NET Framework version 2.0.

Gets the current number of ticks in the timer mechanism.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public static long GetTimestamp ()
public static long GetTimestamp ()
public static function GetTimestamp () : long

Return Value

A long integer representing the tick counter value of the underlying timer mechanism.

If the Stopwatch class uses a high-resolution performance counter, GetTimestamp returns the current value of that counter. If the Stopwatch class uses the system timer, GetTimestamp returns the current DateTime.Ticks property of the DateTime.Now instance.

The following example illustrates setting a performance counter with the GetTimestamp method.

// Create the performance counter.
PerformanceCounter PC = new PerformanceCounter(categoryName, 
                                               counterName, 
                                               false);
// Initialize the counter.
PC.RawValue = Stopwatch.GetTimestamp();

// Create the performance counter.
PerformanceCounter pc = new PerformanceCounter(categoryName,
    counterName, false);
// Initialize the counter.
pc.set_RawValue(Stopwatch.GetTimestamp());

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: