timer

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

Guest

HI,

I need to have a blinking battery in my application. I thought timer is the
best way to make that...
My problem is that my timer is disabled when my application starts and when
timBattBlink_Tick never executes eventhoug I changed enabled = true...
Any ideas why this is happining??

Private Sub shutDown(ByVal instState As String)
If instState = "wait for shutdown" Then
Me.picBattery.Visible = True
timBattBlink.Interval = 500
timBattBlink.Enabled = True
Else
Me.picBattery.Visible = False
timBattBlink.Enabled = False
End If

End Sub

Public Sub timBattBlink_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles timBattBlink.Tick
If Me.picBattery.Visible = True Then
Me.picBattery.Visible = False
Else
Me.picBattery.Visible = True
End If
End Sub
 
Hai,

You need to start the timer if you want the timer to tick.

So apart from enabling the timBattBlink.enabled = True, have

timBattBlink.start()

Try to even refresh the picture just in case.

Me.picBattery.refresh()

Hope it helps..
 
Lamis said:
HI,

I need to have a blinking battery in my application. I thought timer
is the best way to make that...
My problem is that my timer is disabled when my application starts
and when timBattBlink_Tick never executes eventhoug I changed
enabled = true... Any ideas why this is happining??

Private Sub shutDown(ByVal instState As String)
If instState = "wait for shutdown" Then
Me.picBattery.Visible = True
timBattBlink.Interval = 500
timBattBlink.Enabled = True
Else
Me.picBattery.Visible = False
timBattBlink.Enabled = False
End If

End Sub

Public Sub timBattBlink_Tick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles timBattBlink.Tick
If Me.picBattery.Visible = True Then
Me.picBattery.Visible = False
Else
Me.picBattery.Visible = True
End If
End Sub


What does your application do while the battery is to be blinking? Does it
do nothing (ie. waiting for your input) or is it doing anything?


Armin
 
Hi,
My application is doing alot of other things, I have 4 other timers going on
and alot of threads..
this timer works very well if it's enabled from the start. When I disable
it, it never works again.
 
You can display an animated gif just like any picture inside a picture
box. You'll either have to find an animated gif of a battery on the
internet or make one yourself. I have never created one myself I know
there is software that will let you. Search Google for animated gif and
you'll find lots of animated gifs to test. Using an animated gif will
not require any fancy coding to allow your program to continue working
while the "battery blinks".
 
Lamis said:
Hi,
My application is doing alot of other things, I have 4 other timers
going on and alot of threads..
this timer works very well if it's enabled from the start. When I
disable it, it never works again.


I didn't know there are more threads. Rephrased question:
What does your thread that started the timer do while the battery is to be
blinking? Does it do nothing (ie. waiting for your input) or does it doing
anything? I asked because if you start a long running task in the same
thread after enabling the timer, this would explain that the Timer doesn't
fire anymore. Did you also check that the code is executed at all? BTW, I
wouldn't compare against a string.


Armin
 
Back
Top