vb.net - How to keep a Timer running after a program is closed? -
i have vb.net program uses timer 20 seconds. when program runs, timer works fine until finishes (for 20 seconds). problem if close program after 10 seconds, timer stops well. however, want code allows timer continue running until finishes remaining 10 seconds. question is, possible use timer , make run after program closed? alternatively, there other ways accomplish want (example: keep timeofday.ticks run if close program)? solutions appreciated. thanks, a-tech
i'm not sure can continue run after closing, can postpone application closing following code.
public class form1 dim closer boolean = false private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click timer1.enabled = true label1.text = "timer started" end sub private sub timer1_tick(byval sender system.object, byval e system.eventargs) handles timer1.tick timer1.enabled = false label1.text = "timer stopped" if closer application.exit() end if end sub private sub form1_formclosing(byval sender system.object, byval e system.windows.forms.formclosingeventargs) handles mybase.formclosing if timer1.enabled closer = true e.cancel = true end if end sub end class
Comments
Post a Comment