Constancia

VB_Timers_en_Paralelo

May 27th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TIMERS EN PARALELO
  2. http://stackoverflow.com/questions/7923217/two-timers-running-simultaneously-and-independently
  3.  
  4. ESTE FUNCIONA
  5.  'Define your timer objects in your form:
  6. PrivateShared timer1 As System.Timers.Timer
  7. PrivateShared timer2 As System.Timers.Timer
  8.  
  9.  
  10.  'Define Two Handlers for the Elapsed Events:
  11. PublicSub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)'code for timer1 hereendsub
  12. PublicSub Timer2_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs)'code for timer2 hereendsub
  13.  
  14.  'Then in your button click you can add the handlers and start the timers:
  15. Public Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click
  16.     'Add handlers programatically
  17.    AddHandler timer1.Elapsed,AddressOf Timer1_Tick
  18.     AddHandler timer2.Elapsed,AddressOf Timer2_Tick
  19.  
  20.     'Set up the timer intervals and start them
  21.    timer1.Interval =1000
  22.     timer1.enabled =true
  23.     timer2.Interval =5000
  24.     timer2.Enabled =True
  25. End sub
Advertisement
Add Comment
Please, Sign In to add comment