Table of Contents

Class Stopwatch

Namespace
System.Diagnostics
Assembly
System.Diagnostics.Stopwatch.dll

Provides a set of methods and properties that you can use to accurately measure elapsed time.

public class Stopwatch
Inheritance
Stopwatch
Inherited Members
Extension Methods

Constructors

Stopwatch()

public Stopwatch()

Fields

Frequency

Gets the frequency of the timer as the number of ticks per second. This field is read-only.

public static readonly long Frequency

Field Value

long

IsHighResolution

Indicates whether the timer is based on a high-resolution performance counter. This field is read-only.

public static readonly bool IsHighResolution

Field Value

bool

Properties

Elapsed

Gets the total elapsed time measured by the current instance.

public TimeSpan Elapsed { get; }

Property Value

TimeSpan

ElapsedMilliseconds

Gets the total elapsed time measured by the current instance, in milliseconds.

public long ElapsedMilliseconds { get; }

Property Value

long

ElapsedTicks

Gets the total elapsed time measured by the current instance, in timer ticks.

public long ElapsedTicks { get; }

Property Value

long

IsRunning

Gets a value indicating whether the System.Diagnostics.Stopwatch timer is running.

public bool IsRunning { get; }

Property Value

bool

Methods

GetTimestamp()

Gets the current number of ticks in the timer mechanism.

public static long GetTimestamp()

Returns

long

Number of ticks.

Reset()

Stops time interval measurement and resets the elapsed time to zero.

public void Reset()

Restart()

Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.

public void Restart()

Start()

Starts, or resumes, measuring elapsed time for an interval.

public void Start()

StartNew()

Initializes a new System.Diagnostics.Stopwatch instance, sets the elapsed time property to zero, and starts measuring elapsed time.

public static Stopwatch StartNew()

Returns

Stopwatch

A System.Diagnostics.Stopwatch that has just begun measuring elapsed time.

Stop()

Stops measuring elapsed time for an interval.

public void Stop()