Hey guys, first of all I just wanted to say thanks for all the help given in the past couple weeks. Ive learned a ton and my program has been saving me hours and hours of work every day.

I want to expand it a little bit and add a second timer that runs parallel to the first timer, but is not affected in any way shape or form by the first timer.

I want the timers to run like this:

Time Timer1 Timer2
0 X X
1 X
2 X
3 X
4 X
5 X X
6 X
7 X
8 X
9 X
10 X X


Ive tried nesting the second loop in the first loop but the second loop takes 3 seconds to complete, so I found that it froze the first loop till the second loop finishes. I was reading about system threading (System.Timers.Timer) and it seems like that is the route I want to go.

I wrote this quick as an example:

This assumes that I added a windows timer control as timer1

vb Code:
  1. Option Strict On
  2. Imports System
  3. Imports System.Timers
  4.  
  5. public class form1
  6.  
  7.     Private Shared timer2 As System.Timers.Timer
  8.         timer2 = New System.Timers.Timer
  9.         AddHandler timer2.Elapsed, AddressOf OnTimedEvent
  10.        
  11.  
  12.     Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.  
  14. timer1.Interval = 1000
  15. timer1.enabled = true
  16. timer2.Interval = 5000
  17. timer2.Enabled = True
  18.  
  19. End sub
  20.  
  21. Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  22.  
  23. 'code for timer1 here
  24.  
  25. end sub
  26.  
  27.     Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
  28.  
  29.         'code for timer2 here
  30.  
  31.     end sub
  32.  
  33. end class


Does this even make sense... or did I just spend the last 20 minutes making up my own language?