Bagikan melalui


DateAndTime.Timer Properti

Definisi

Mengembalikan nilai Double yang menunjukkan jumlah detik yang berlalu sejak tengah malam.

public:
 static property double Timer { double get(); };
public static double Timer { get; }
static member Timer : double
Public ReadOnly Property Timer As Double

Nilai Properti

Nilai yang menunjukkan jumlah detik yang berlalu sejak tengah malam.

Contoh

Contoh ini menggunakan Timer properti untuk menjeda aplikasi. Ini dapat melakukan pemrosesan lain selama jeda.

Public Sub waitFiveSeconds()
    If TimeOfDay >= #11:59:55 PM# Then
        MsgBox("The current time is within 5 seconds of midnight" & 
            vbCrLf & "The timer returns to 0.0 at midnight")
        Return
    End If
    Dim start, finish, totalTime As Double
    If (MsgBox("Press Yes to pause for 5 seconds", MsgBoxStyle.YesNo)) =
         MsgBoxResult.Yes Then

        start = Microsoft.VisualBasic.DateAndTime.Timer
        ' Set end time for 5-second duration.
        finish = start + 5.0
        Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
        ' Do other processing while waiting for 5 seconds to elapse.
        Loop
        totalTime = Microsoft.VisualBasic.DateAndTime.Timer - start
        MsgBox("Paused for " & totalTime & " seconds")
    End If
End Sub

Perhatikan bahwa Anda harus memenuhi syarat properti dengan Microsoft.VisualBasic namespace, karena Timer juga merupakan kelas yang ditentukan di System.Threadingnamespace , , System.Timers, dan System.Windows.Forms .Timer

Keterangan

Properti Timer mengembalikan detik dan milidetik sejak tengah malam terbaru. Detik berada di bagian integral dari nilai yang dikembalikan, dan milidetik berada di bagian pecahan.

Berlaku untuk

Lihat juga