vb.net - (VB) Timer carries on other forms -
basically, when continue onto next form timer still running, how can stop this? have used "timer1.enabled = false"
private sub timer1_tick(sender object, e eventargs) handles timer1.tick msgbox("sorry, time has expired. please try again.", vbokonly, "warning") me.close() end sub
i think using windows timer.
if true first message box has unwanted side effect accumulate number of tick events in message queue of program.
more time stay in video message box displayed more message boxes displayed because messages accumulate in queue
you try solve situation global form variable
dim timeelapsed boolean private sub timer1_tick(sender object, e eventargs) handles timer1.tick if timeelapsed = false timeelapsed = true ' important set immediatly true msgbox("sorry, time has expired. please try again.", vbokonly, "warning") me.close() dim t = ctype(sender, timer) t.elapsed = false end if end sub
also check hans passant advice disposing of timer
Comments
Post a Comment