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.
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.