473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Delay the execution of a line of code??

My program is supposed to play a wav file of a ticking clock using the media player object so that only after the file is over (this is to build tension), some textboxes are populated with data generated in a subroutine called givegroups.

Everything is working fine, except for the fact that the textboxes are being populated as soon as the audio clip starts playing, therefore no tension is being built. I've tried using threading.thread.sleep(10000) by writing it under the subroutine that plays the file (called StartClockTick) but over the subroutine that populates the textboxes (givegroups) with dissapointing results. (it still fills in the textboxes as soon as the audio file starts playing).

How can I make the program to play the whole 10 seconds of audio file, before reading the subroutine "givegroups" that populates the textboxes?

Here is the relevant code:

Private Sub MakeGroupsBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MakeGroupsBtn.Click
Call StartClockTick()
'It loads the audio file to the media player object and plays it.
Call givegroups(playersarray)
'It populted the textboxes in the form. This should happen after the
audio file has been played compeltely (it lasts 9 seconds).
End Sub

Private Sub StartClockTick()
Timer2.Enabled = True
Timer2.Start()
myPlaya.URL = "C:\Documents and Settings\Juan M. Lemus\
MyDocuments\My Music\ClockTick.wav"
myPlaya.Ctlcontrols.play()
End Sub

Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim timeStr, lengthStr As String
timeStr = myPlaya.Ctlcontrols.currentPositionString
lengthStr = myPlaya.currentMedia.durationString
StatusStrip1.Items.Item(1).Text = timeStr & " / " & lengthStr

Dim length As Integer, time As Integer
time = myPlaya.Ctlcontrols.currentPosition
length = myPlaya.currentMedia.duration
If (length > 0) Then
pbrGroups.Value = 100 * (time / length)
End If
End Sub

NB: The timer2 is a timer object used to dynamically update a progress bar that monitors the progress of the audio file.
Sep 4 '07 #1
0 1269

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have...
8
by: Jason Shohet | last post by:
Lets say I want a button to execute 10 seconds after I press it, not immediately. Any ideas how to cause that, in a code-behind. IMO its only server side code, I don't think javascript needs to...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
1
by: klmishraa79 | last post by:
i want to know how i can put a time delay between two command execution...i.e. after first command of programm the second command should execute after some fixed delay......i want to use time delay...
4
by: coolsti | last post by:
I have an applet that accepts data as a stream from a php script using the following code snippet: String dataendpoint = "http://phpfunction.php"; URL url = new...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.