Best way to create a timer app.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've built a CF program and I would like to keep track of the seconds elapsed
since the user does a certain funtion (i.e. click on a button, etc.)

I've tried to use the Environment.TickCount method and the Forms.Timer
control, but both seem to fall behind a couple of seconds after a few
minutes pass.

Here is how I was trying to use Environment.TickCount methods (first couple
of lines are items set elsewhere in the program):
'## Timer1 begins as Enabled=False
'## When Button1 is clicked, Timer1.Enabled = True
'## giStart is an Int32 declared as private for the class

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim iEnd As Int32

If giStart = 0 Then giStart = Environment.TickCount

iEnd = Environment.TickCount
Me.Label1.Text = iEnd - giStart '(displays in milliseconds)
End Sub

For the Forms.Timer Control, I was incrementing a variable by 1 and then
displaying to the screen (similar to what I was doing with the other method).

Basically, what I'm looking to do is show a timer on the screen that has a
pause button, which will halt the timer until they press it again.

Should I be trying a different way to accomplish this? Maybe with threads?

Thanks.
 
I ran the app from the desktop emulator and timed it with my watch. It seems
to fall a bit behind after a couple of minutes running. Do you think it's a
problem of the emulator?
 
Clock on the emulator has so many problems I'm not sure where to start.
Whatever method you use, you will see it. You need an actual device. In
VS2005 emulator this has been addresse
 
I deploy to my device and see if it stays on track.

Thanks for your time (no pun intended).
 
Back
Top