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:
Option Strict On Imports System Imports System.Timers public class form1 Private Shared timer2 As System.Timers.Timer timer2 = New System.Timers.Timer AddHandler timer2.Elapsed, AddressOf OnTimedEvent Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click timer1.Interval = 1000 timer1.enabled = true timer2.Interval = 5000 timer2.Enabled = True End sub Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'code for timer1 here end sub Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs) 'code for timer2 here end sub end class
Does this even make sense... or did I just spend the last 20 minutes making up my own language?




Reply With Quote
