Stopwatch.IsHighResolution Feld

Definition

Gibt an, ob der Timer auf einem hochauflösenden Leistungsindikator basiert.Indicates whether the timer is based on a high-resolution performance counter. Dieses Feld ist schreibgeschützt.This field is read-only.

public: static initonly bool IsHighResolution;
public static readonly bool IsHighResolution;
 staticval mutable IsHighResolution : bool
Public Shared ReadOnly IsHighResolution As Boolean 

Feldwert

Boolean

Beispiele

Im folgenden Beispiel wird die Häufigkeit und Auflösung eines Stopwatch Timers angezeigt.The following example displays the frequency and resolution of a Stopwatch timer. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die-Klasse bereitgestellt wird Stopwatch .This code example is part of a larger example provided for the Stopwatch class.

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." );
   }

   Int64 frequency = Stopwatch::Frequency;
   Console::WriteLine( "  Timer frequency in ticks per second = {0}", frequency );
   Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
   Console::WriteLine( "  Timer is accurate within {0} nanoseconds", nanosecPerTick );
}
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

Hinweise

Der von der-Klasse verwendete Timer Stopwatch hängt von der System Hardware und dem Betriebssystem ab.The timer used by the Stopwatch class depends on the system hardware and operating system. IsHighResolution gibt true an, ob der Stopwatch Zeitgeber auf einem Leistungs Zähler mit hoher Auflösung basiert.IsHighResolution is true if the Stopwatch timer is based on a high-resolution performance counter. Andernfalls ist der Wert IsHighResolution false , der angibt, dass der Stopwatch Timer auf dem systemtimer basiert.Otherwise, IsHighResolution is false, which indicates that the Stopwatch timer is based on the system timer.

Gilt für:

Siehe auch