Bagikan melalui


Stopwatch.IsHighResolution Bidang

Definisi

Menunjukkan apakah timer didasarkan pada penghitung kinerja resolusi tinggi. Bidang ini hanya-baca.

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

Nilai Bidang

Contoh

Contoh berikut menampilkan frekuensi dan resolusi Stopwatch timer. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk Stopwatch kelas .

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

Keterangan

Timer yang Stopwatch digunakan oleh kelas tergantung pada perangkat keras sistem dan sistem operasi. IsHighResolution adalah true jika timer Stopwatch didasarkan pada penghitung kinerja resolusi tinggi. Jika tidak, IsHighResolution adalah false, yang menunjukkan bahwa timer Stopwatch didasarkan pada timer sistem.

Berlaku untuk

Lihat juga