Compact Framework - getting clock tick for device

Can Anybody Help?
I need to get the low level clock ticks for a timing program on the Pocket PC - I am using VB.Net 2005. I have found this article on MSDN:
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.devices.clock.tickcount.aspx
As you can see it refers to devices in the address and one supposes that it is "what it says on the tin".
However, when placing the example code from this page onto the PPC emulation in Visual Studio (VB) I get the message:
" 'Computer' is not a member of My "
It seems as if Microsoft has an unexplained contradiction in that "My.Computer" is not part of the Compact Framework but is issuing code that includes "My.Computer"
You can get the code from the link but I have dropped it n below...I think the code is for non compact framework and Microsoft have goofed - or I have!
Can anyone suggest anything? I know it can be done as a one time colleague got it working in embedded VB.

Public Sub LoopTask(ByVal secondsToRun As Integer)
    Dim startTicks As Integer = My.Computer.Clock.TickCount
    Do While IsTimeUp(startTicks, secondsToRun)
        ' Code to run for at least secondsToRun seconds goes here.
    Loop
End Sub
 
Private Function IsTimeUp( _
    ByVal startTicks As Integer, _
    ByVal seconds As Integer _
) As Boolean
    ' This function throws an overflow exception if the
    ' tick count difference is greater than 2,147,483,647,  
    ' about 24 days for My.Computer.Clock.TickCount.
 
    ' Use UInteger to simplify the code for roll over.
    Dim uStart As UInteger = _
        CUInt(CLng(startTicks) - Integer.MinValue)
    Dim uCurrent As UInteger = _
        CUInt(CLng(My.Computer.Clock.TickCount) - Integer.MinValue)
 
    ' Calculate the tick count difference.
    Dim tickCountDifference As UInteger
    If uStart <= uCurrent Then
        tickCountDifference = uCurrent - uStart
    Else
        ' Tick count rolled over.
        tickCountDifference = UInteger.MaxValue - (uStart - uCurrent)
    End If
 
    ' Convert seconds to milliseconds and compare.
    Return CInt(tickCountDifference) < (seconds * 1000)
End Function

Open in new window

AgentDigbyAsked:
Who is Participating?
 
alexey_gusevConnect With a Mentor Commented:
Environment.TickCount gives you the timer ticks

some unrelated samples are e.g. here: http://stackoverflow.com/questions/243351/environment-tickcount-vs-datetime-now

0
 
AgentDigbyAuthor Commented:
Thanks - for ever in your debt!
Worth staying up for - it really works...
A million thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.