Constancia icon

VB_Timers_en_Paralelo

Constancia | PRO | 05/27/13 09:48:26 PM UTC | 0 ⭐ | 145 👁️ | Never ⏰ | []
VisualBasic |

1 KB

|

None

|

0 👍

/

0 👎

TIMERS EN PARALELO
http://stackoverflow.com/questions/7923217/two-timers-running-simultaneously-and-independently
 
ESTE FUNCIONA
 'Define your timer objects in your form:
PrivateShared timer1 As System.Timers.Timer
PrivateShared timer2 As System.Timers.Timer
 
 
 'Define Two Handlers for the Elapsed Events:
PublicSub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)'code for timer1 hereendsub
PublicSub Timer2_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)'code for timer2 hereendsub
 
 'Then in your button click you can add the handlers and start the timers:
Public Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click
    'Add handlers programatically
    AddHandler timer1.Elapsed,AddressOf Timer1_Tick
    AddHandler timer2.Elapsed,AddressOf Timer2_Tick
 
    'Set up the timer intervals and start them
    timer1.Interval =1000
    timer1.enabled =true
    timer2.Interval =5000
    timer2.Enabled =True
End sub

Comments