Stopwatch.IsHighResolution Champ

Définition

Indique si la minuterie est basée sur un compteur de performance haute résolution. Ce champ est en lecture seule.

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

Valeur de champ

Exemples

L’exemple suivant affiche la fréquence et la résolution d’un Stopwatch minuteur. Cet exemple de code fait partie d’un exemple plus grand fourni pour la Stopwatch classe .

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

Remarques

Le minuteur utilisé par la Stopwatch classe dépend du matériel système et du système d’exploitation. IsHighResolution est true si le Stopwatch minuteur est basé sur un compteur de performances haute résolution. Sinon, IsHighResolution est false, ce qui indique que le Stopwatch minuteur est basé sur le minuteur système.

S’applique à

Voir aussi