Frequency Campo
Collapse the table of content
Expand the table of content
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
Traducción
Original

Stopwatch.Frequency (Campo)

 

Obtiene la frecuencia del temporizador en forma de número de tics por segundo.Este campo es de solo lectura.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

public static readonly long Frequency

Valor de campo

Type: System.Int64

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 Frequency 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 Frequency value reflects the frequency of that counter.Otherwise, the Frequency value is based on the system timer frequency.

Because the Stopwatch frequency depends on the installed hardware and operating system, the Frequency value remains constant while the system is running.

The following example displays the frequency and resolution of a Stopwatch timer.This code example is part of a larger example provided for the Stopwatch class.

public static void DisplayTimerProperties()
{
    // Display the timer frequency and resolution.
    if (Stopwatch.IsHighResolution)
    {
        Console.WriteLine("Operations timed using the system's high-resolution performance counter.");
    }
    else 
    {
        Console.WriteLine("Operations timed using the DateTime class.");
    }

    long frequency = Stopwatch.Frequency;
    Console.WriteLine("  Timer frequency in ticks per second = {0}",
        frequency);
    long nanosecPerTick = (1000L*1000L*1000L) / frequency;
    Console.WriteLine("  Timer is accurate within {0} nanoseconds", 
        nanosecPerTick);
}

Universal Windows Platform
Disponible desde 4.5
.NET Framework
Disponible desde 2.0
Portable Class Library
Compatible con: portable .NET platforms
Windows Phone Silverlight
Disponible desde 7.0
Windows Phone
Disponible desde 8.1
Volver al principio
Mostrar:
© 2016 Microsoft