Passing Variables to timers

ncarter33

New member
Joined
Jul 27, 2009
Messages
1
Programming Experience
5-10
Hi

I have a form that holds min two timers,
One is a 72 hour timer and one is a 12 hour timer.

What I am trying to do is have both run at the same time, when the 12 hour timer expires it'll bring up a form informing the user that in 60 hours the machine will reboot (or they can just hit reboot).
When the 72 hour timer expires it reboots the machine.

BUT I know my managment is going to want to be flexable. e.g instead of 72 hours make is 54, and instead of 12 make it 6.

I wish to avoid using global variables

This is the code for the 12 hour one, How do I call it and set i12sec and i12min?

************************************************
Private Sub t12hTimer_Tick(sender As System.Object, e As System.EventArgs, i12sec As Integer, i12min As Integer) Handles t12hTimer.Tick


t12hTimer.Interval = 1000 '1000 Miliseconds = 1 second

If t12hTimer.Enabled = True Then
i12sec = i12sec - 1
If i12sec = -1 Then i12min = i12min - 1
If i12sec = -1 Then i12sec = 59
If i12min = 0 And i12sec = 0 Then
t12hTimer.Enabled = False
MsgBox("Times up", MsgBoxStyle.OkOnly, "12 Hour Timer Time's Up")
End If
End If

Me.l12mLabel.Text = i12min
Me.l12SLabel.Text = i12sec

End Sub
 
why dont you just use minutes? or seconds ?

Or look at comparing the time between two points (system time when the counter started and the current system time).

Why can't you use global vars? You could always make a class, then have some methods in there like 'myclass.tick' and the class could manage the actual calculations? Depends how far you want to go really.

Or if you are worried about hard coding the values, maybe keep them in the registry or in a text file somewhere? (then you can change them, maybe even using group polices if its a domain based network).
 
Back
Top