TickCount Property


TickCount Property

Location

My.Computer.Clock.TickCount

Syntax

     Dim result As Integer = My.Computer.Clock.TickCount 

Description

The TickCount property returns the current millisecond count of the system timer, although with limited granularity.

Usage at a Glance

  • This property is read-only.

  • The system timer has a limited resolution and is not accurate to more than 500 milliseconds.

  • After about 24.9 days, the TickCount value reaches the maximum integer value (System.Int32.MaxValue). It then jumps to the minimum integer value, a negative number (System.Int32.MinValue), and continues incrementing in the positive direction.

  • The system timer may stop incrementing when the system is in certain power-saving states, such as hibernation.

Example

The following example returns the number of milliseconds that have elapsed since the last time the function was called.

     Public Function SinceLastCall(  ) As Integer        ' ----- Return the number of milliseconds since the        '       last call of this routine.        Static lastTime As Integer = -1        Dim thisTime As Integer        ' ----- Get the current tick count and compare to last time.        thisTime = My.Computer.Clock.TickCount        If (lastTime = -1) Then lastTime = thisTime        If (thisTime < lastTime) Then           ' ----- The integer value wrapped.           SinceLastCall = (Integer.MaxValue - lastTime) + _              (thisTime - Integer.MinValue)        Else           ' ----- Simple advance of the timer.           SinceLastCall = thisTime - lastTime        End If        lastTime = thisTime     End Function 

Related Framework Entries

  • Microsoft.VisualBasic.Devices.Clock.TickCount Property

  • System.Environment.TickCount Property

See Also

Clock Object, GmtTime Property, LocalTime Property




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net