Export (0) Print
Expand All

Stopwatch.GetTimestamp Method

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
Not applicable.

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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft