|
-
Oct 20th, 2005, 01:29 PM
#1
Thread Starter
Member
Time delay in loop
Time delay in loop
Hello
I am trying to put a 5 seconds time delay into a loop.
The following code isn't working.
Any ideas, please?
Thank you.
[CUT-DOWN CODE]
Code:
Public theshowresultstimer As New System.Timers.Timer(5000)
do
Beep()
Me.theshowresultstimer.Start()
Beep()
loop while....
-
Oct 20th, 2005, 01:29 PM
#2
-
Oct 20th, 2005, 01:33 PM
#3
Thread Starter
Member
Re: Time delay in loop
Cor, mendhak. That was quick!
Just out of curiosity, is there any way to do this without stopping the entire thread?
-
Oct 20th, 2005, 01:41 PM
#4
Re: Time delay in loop
Isn't that what you wanted? Can you elaborate?
-
Oct 20th, 2005, 01:46 PM
#5
Re: Time delay in loop
 Originally Posted by mancroft
Cor, mendhak. That was quick!
Just out of curiosity, is there any way to do this without stopping the entire thread?
Well you may do your loop into another thread
-
Oct 20th, 2005, 01:50 PM
#6
Thread Starter
Member
Re: Time delay in loop
 Originally Posted by mendhak
Isn't that what you wanted? Can you elaborate?
Well, the code below is for another timer (for 45 seconds) but this one fires off a button click and does not appear to stop the entire program.
What i'd like is something like that but in a loop without a button trigger.
Code:
Dim thetimer As New System.Timers.Timer(45000)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler thetimer.Elapsed, AddressOf TimerFired
End sub
Public Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
Beep()
thetimer.Enabled = False
flag = 2
End Sub
-
Oct 20th, 2005, 02:36 PM
#7
Re: Time delay in loop
Why don't you just put the Beep() in the Tick Event of the Timer??? That way the Beep() would fire at every interval of the timer...
** Sorry... didnt read your last post.. seems thats what youre doing now...
You would just put your interval for 5000, for 5 seconds, then you can have a variable that you increment in the Tick event..., like a Counter (declared outside of the timer). Then when that counter is 9 (9*5 = 45), then disable the timer and call the code you need...
Last edited by gigemboy; Oct 20th, 2005 at 02:39 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|