Stopwatch.IsHighResolution Campo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Indica se il timer è basato su un contatore delle prestazioni ad alta risoluzione. Questo campo è di sola lettura.
public: static initonly bool IsHighResolution;
public static readonly bool IsHighResolution;
staticval mutable IsHighResolution : bool
Public Shared ReadOnly IsHighResolution As Boolean
Valore del campo
Esempio
Nell'esempio seguente viene visualizzata la frequenza e la risoluzione di un Stopwatch timer. Questo esempio di codice fa parte di un esempio più ampio fornito per la Stopwatch classe .
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);
}
Public Shared Sub DisplayTimerProperties()
' Display the timer frequency and resolution.
If Stopwatch.IsHighResolution Then
Console.WriteLine("Operations timed using the system's high-resolution performance counter.")
Else
Console.WriteLine("Operations timed using the DateTime class.")
End If
Dim frequency As Long = Stopwatch.Frequency
Console.WriteLine(" Timer frequency in ticks per second = {0}", frequency)
Dim nanosecPerTick As Long = 1000000000 / frequency
Console.WriteLine(" Timer is accurate within {0} nanoseconds", nanosecPerTick)
End Sub
Commenti
Il timer usato dalla Stopwatch classe dipende dall'hardware del sistema e dal sistema operativo.
IsHighResolution è true se il Stopwatch timer è basato su un contatore delle prestazioni ad alta risoluzione. In caso contrario, IsHighResolution è false, che indica che il Stopwatch timer è basato sul timer di sistema.