Class Stopwatch
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Inherited Members
Namespace: System.Diagnostics
Assembly: System.Diagnostics.Stopwatch.dll
Syntax
public class Stopwatch
Fields
| Improve this Doc View SourceFrequency
Gets the frequency of the timer as the number of ticks per second. This field is read-only.
Declaration
public static readonly long Frequency
Field Value
| Type | Description |
|---|---|
| Int64 |
IsHighResolution
Indicates whether the timer is based on a high-resolution performance counter. This field is read-only.
Declaration
public static readonly bool IsHighResolution
Field Value
| Type | Description |
|---|---|
| Boolean |
Properties
| Improve this Doc View SourceElapsed
Gets the total elapsed time measured by the current instance.
Declaration
public TimeSpan Elapsed { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
ElapsedMilliseconds
Gets the total elapsed time measured by the current instance, in milliseconds.
Declaration
public long ElapsedMilliseconds { get; }
Property Value
| Type | Description |
|---|---|
| Int64 |
ElapsedTicks
Gets the total elapsed time measured by the current instance, in timer ticks.
Declaration
public long ElapsedTicks { get; }
Property Value
| Type | Description |
|---|---|
| Int64 |
IsRunning
Gets a value indicating whether the System.Diagnostics.Stopwatch timer is running.
Declaration
public bool IsRunning { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Methods
| Improve this Doc View SourceGetTimestamp()
Gets the current number of ticks in the timer mechanism.
Declaration
public static long GetTimestamp()
Returns
| Type | Description |
|---|---|
| Int64 | Number of ticks. |
Reset()
Stops time interval measurement and resets the elapsed time to zero.
Declaration
public void Reset()
Restart()
Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
Declaration
public void Restart()
Start()
Starts, or resumes, measuring elapsed time for an interval.
Declaration
public void Start()
StartNew()
Initializes a new System.Diagnostics.Stopwatch instance, sets the elapsed time property to zero, and starts measuring elapsed time.
Declaration
public static Stopwatch StartNew()
Returns
| Type | Description |
|---|---|
| Stopwatch | A System.Diagnostics.Stopwatch that has just begun measuring elapsed time. |
Stop()
Stops measuring elapsed time for an interval.
Declaration
public void Stop()