System 2.0.0.0 4.0.0.0 System.Object A instance can measure elapsed time for one interval, or the total of elapsed time across multiple intervals. In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. A instance is either running or stopped; use to determine the current state of a . Use to begin measuring elapsed time; use to stop measuring elapsed time. Query the elapsed time value through the properties , , or . You can query the elapsed time properties while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. The measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the class uses that counter to measure elapsed time. Otherwise, the class uses the system timer to measure elapsed time. Use the and fields to determine the precision and resolution of the timing implementation. The class assists the manipulation of timing-related performance counters within managed code. Specifically, the field and method can be used in place of the unmanaged Win32 APIs QueryPerformanceFrequency and QueryPerformanceCounter. On a multiprocessor computer, it does not matter which processor the thread runs on. However, because of bugs in the BIOS or the Hardware Abstraction Layer (HAL), you can get different timing results on different processors. To specify processor affinity for a thread, use the method. Provides a set of methods and properties that you can use to accurately measure elapsed time. Constructor 2.0.0.0 4.0.0.0 The returned instance is stopped, and the elapsed time property of the instance is zero. Use the method to begin measuring elapsed time with the new instance. Use the method to initialize a new instance and immediately start it. Initializes a new instance of the class. Property 2.0.0.0 4.0.0.0 System.TimeSpan To be added. In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. Use the property to retrieve the elapsed time value using methods and properties. For example, you can format the returned instance into a text representation, or pass it to another class that requires a parameter. You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. Gets the total elapsed time measured by the current instance. Property 2.0.0.0 4.0.0.0 System.Int64 To be added. This property represents elapsed time rounded down to the nearest whole millisecond value. For higher precision measurements, use the or properties. You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. Gets the total elapsed time measured by the current instance, in milliseconds. Property 2.0.0.0 4.0.0.0 System.Int64 To be added. This property represents the number of elapsed ticks in the underlying timer mechanism. A tick is the smallest unit of time that the timer can measure. Use the field to convert the value into a number of seconds. You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. ticks are different from . Each tick in the value represents one 100-nanosecond interval. Each tick in the value represents the time interval equal to 1 second divided by the . Gets the total elapsed time measured by the current instance, in timer ticks. Field 2.0.0.0 4.0.0.0 System.Int64 10000000 The timer frequency indicates the timer precision and resolution. For example, a timer frequency of 2 million ticks per second equals a timer resolution of 500 nanoseconds per tick. In other words, because one second equals 1 billion nanoseconds, a timer frequency of 2 million ticks per second is equivalent to 2 million ticks per 1 billion nanoseconds, which can be further simplified to 1 tick per 500 nanoseconds. The value depends on the resolution of the underlying timing mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the value reflects the frequency of that counter. Otherwise, the value is based on the system timer frequency. Because the frequency depends on the installed hardware and operating system, the value remains constant while the system is running. Gets the frequency of the timer as the number of ticks per second. This field is read-only. Method 2.0.0.0 4.0.0.0 System.Int64 If the class uses a high-resolution performance counter, returns the current value of that counter. If the class uses the system timer, returns the current property of the instance. Gets the current number of ticks in the timer mechanism. A long integer representing the tick counter value of the underlying timer mechanism. Field 2.0.0.0 4.0.0.0 System.Boolean The timer used by the class depends on the system hardware and operating system. is true if the timer is based on a high-resolution performance counter. Otherwise, is false, which indicates that the timer is based on the system timer. Indicates whether the timer is based on a high-resolution performance counter. This field is read-only. Property 2.0.0.0 4.0.0.0 System.Boolean To be added. A instance begins running with a call to or . The instance stops running with a call to or . Gets a value indicating whether the timer is running. Method 2.0.0.0 4.0.0.0 System.Void A instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. Stops time interval measurement and resets the elapsed time to zero. Method 4.0.0.0 System.Void A instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset or restarted. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. Use to stop current interval measurement and start a new interval measurement. Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. Method 2.0.0.0 4.0.0.0 System.Void In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. Once started, a timer measures the current interval, in elapsed timer ticks, until the instance is stopped or reset. Starting a that is already running does not change the timer state or reset the elapsed time properties. When a instance measures more than one interval, the method resumes measuring time from the current elapsed time value. A instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use the method before calling to clear the cumulative elapsed time in a instance. Use the method to and the with a single command. Starts, or resumes, measuring elapsed time for an interval. Method 2.0.0.0 4.0.0.0 System.Diagnostics.Stopwatch This method is equivalent to calling the constructor and then calling on the new instance. Initializes a new instance, sets the elapsed time property to zero, and starts measuring elapsed time. A that has just begun measuring elapsed time. Method 2.0.0.0 4.0.0.0 System.Void In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. The method ends the current time interval measurement. Stopping a that is not running does not change the timer state or reset the elapsed time properties. When a instance measures more than one interval, the method is equivalent to pausing the elapsed time measurement. A subsequent call to resumes measuring time from the current elapsed time value. Use the method to clear the cumulative elapsed time in a instance. Stops measuring elapsed time for an interval.