Stopwatch.IsHighResolution Veld
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Geeft aan of de timer is gebaseerd op een prestatiemeteritem met hoge resolutie. Dit veld is alleen-lezen.
public: static initonly bool IsHighResolution;
public static readonly bool IsHighResolution;
staticval mutable IsHighResolution : bool
Public Shared ReadOnly IsHighResolution As Boolean
Waarde van veld
Voorbeelden
In het volgende voorbeeld wordt de frequentie en resolutie van een Stopwatch timer weergegeven. Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de Stopwatch klasse.
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
Opmerkingen
De timer die door de Stopwatch klasse wordt gebruikt, is afhankelijk van de systeemhardware en het besturingssysteem.
IsHighResolution is true als de Stopwatch timer is gebaseerd op een prestatiemeteritem met hoge resolutie. Anders isfalse, IsHighResolution wat aangeeft dat de Stopwatch timer is gebaseerd op de systeemtimer.