mscorlib(4.0.0.0) API with additions
System.Diagnostics.Stopwatch Class Reference

Provides a set of methods and properties that you can use to accurately measure elapsed time.To browse the .NET Framework source code for this type, see the Reference Source. More...

Public Member Functions

 Stopwatch ()
 Initializes a new instance of the T:System.Diagnostics.Stopwatch class. More...
 
void Start ()
 Starts, or resumes, measuring elapsed time for an interval. More...
 
void Stop ()
 Stops measuring elapsed time for an interval. More...
 
void Reset ()
 Stops time interval measurement and resets the elapsed time to zero. More...
 
void Restart ()
 Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. More...
 

Static Public Member Functions

static Stopwatch StartNew ()
 Initializes a new T:System.Diagnostics.Stopwatch instance, sets the elapsed time property to zero, and starts measuring elapsed time. More...
 
static long GetTimestamp ()
 Gets the current number of ticks in the timer mechanism. More...
 

Static Public Attributes

static readonly long Frequency
 Gets the frequency of the timer as the number of ticks per second. This field is read-only. More...
 
static readonly bool IsHighResolution
 Indicates whether the timer is based on a high-resolution performance counter. This field is read-only. More...
 

Properties

bool IsRunning [get]
 Gets a value indicating whether the T:System.Diagnostics.Stopwatch timer is running. More...
 
TimeSpan Elapsed [get]
 Gets the total elapsed time measured by the current instance. More...
 
long ElapsedMilliseconds [get]
 Gets the total elapsed time measured by the current instance, in milliseconds. More...
 
long ElapsedTicks [get]
 Gets the total elapsed time measured by the current instance, in timer ticks. More...
 

Detailed Description

Provides a set of methods and properties that you can use to accurately measure elapsed time.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 7 of file Stopwatch.cs.

Constructor & Destructor Documentation

◆ Stopwatch()

System.Diagnostics.Stopwatch.Stopwatch ( )

Initializes a new instance of the T:System.Diagnostics.Stopwatch class.

Definition at line 96 of file Stopwatch.cs.

Member Function Documentation

◆ GetTimestamp()

static long System.Diagnostics.Stopwatch.GetTimestamp ( )
static

Gets the current number of ticks in the timer mechanism.

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

Definition at line 160 of file Stopwatch.cs.

◆ Reset()

void System.Diagnostics.Stopwatch.Reset ( )

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

Definition at line 141 of file Stopwatch.cs.

◆ Restart()

void System.Diagnostics.Stopwatch.Restart ( )

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

Definition at line 150 of file Stopwatch.cs.

◆ Start()

void System.Diagnostics.Stopwatch.Start ( )

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

Definition at line 103 of file Stopwatch.cs.

◆ StartNew()

static Stopwatch System.Diagnostics.Stopwatch.StartNew ( )
static

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

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

Definition at line 115 of file Stopwatch.cs.

◆ Stop()

void System.Diagnostics.Stopwatch.Stop ( )

Stops measuring elapsed time for an interval.

Definition at line 124 of file Stopwatch.cs.

Member Data Documentation

◆ Frequency

readonly long System.Diagnostics.Stopwatch.Frequency
static

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

Definition at line 21 of file Stopwatch.cs.

◆ IsHighResolution

readonly bool System.Diagnostics.Stopwatch.IsHighResolution
static

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

Definition at line 25 of file Stopwatch.cs.

Property Documentation

◆ Elapsed

TimeSpan System.Diagnostics.Stopwatch.Elapsed
get

Gets the total elapsed time measured by the current instance.

Returns
A read-only T:System.TimeSpan representing the total elapsed time measured by the current instance.

Definition at line 46 of file Stopwatch.cs.

◆ ElapsedMilliseconds

long System.Diagnostics.Stopwatch.ElapsedMilliseconds
get

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

Returns
A read-only long integer representing the total number of milliseconds measured by the current instance.

Definition at line 58 of file Stopwatch.cs.

◆ ElapsedTicks

long System.Diagnostics.Stopwatch.ElapsedTicks
get

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

Returns
A read-only long integer representing the total number of timer ticks measured by the current instance.

Definition at line 70 of file Stopwatch.cs.

◆ IsRunning

bool System.Diagnostics.Stopwatch.IsRunning
get

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

Returns
true if the T:System.Diagnostics.Stopwatch instance is currently running and measuring elapsed time for an interval; otherwise, false.

Definition at line 34 of file Stopwatch.cs.


The documentation for this class was generated from the following file: