473,403 Members | 2,354 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,403 software developers and data experts.

Windows app, add a thread and pause for audio...

Using VS 2003, VB .NET:
Currently I have a windows app that I'm running in a single thread. Recent
client requests have me interested in learning how to create another thread
and perform an action asyn. to the main GUI app. So my question is pretty
simple, how do I do that. The action that I want performed in the 2nd thread
is to play an audio wav file - possibly putting that thread to sleep for a
while before playing it.
I know how to create a new thread and put it to sleep - I'm just not sure
how to associate my media player with the second thread instead of the main
app thread.

Thanks for your attention to this matter.

-Charles
Oct 6 '05 #1
3 1147
Hi dear Charles("hz****@nopost.com"),

Even though you know how to start a thread, I just give complete info

'First Imort the Threading Class
Imports System.Threading

'Declare a variable
Private trd As Thread

trd = New Thread(AddressOf ThreadTask)
trd.IsBackground = True
trd.Start()

Private Sub ThreadTask()
Thread.Sleep(100)

'do your media player stuff here

End Sub

Thats all.

for anything and everything, please reply back

bye
Venkat_KL

Oct 6 '05 #2
THanks for the quick reply, I do have some questions though.

1. What do I use for "AddressOf ThreadTask"?
2. What associates my media player actions with the 2nd thread - only the
sub routine? I was thinking that the thread needed to somehow register
knowledge of the media player.

Thanks again for your help.

"Venkat_KL" wrote:
Hi dear Charles("hz****@nopost.com"),

Even though you know how to start a thread, I just give complete info

'First Imort the Threading Class
Imports System.Threading

'Declare a variable
Private trd As Thread

trd = New Thread(AddressOf ThreadTask)
trd.IsBackground = True
trd.Start()

Private Sub ThreadTask()
Thread.Sleep(100)

'do your media player stuff here

End Sub

Thats all.

for anything and everything, please reply back

bye
Venkat_KL

Oct 6 '05 #3
Ok,
So I was able to register a ThreadTask method that gets called by the
Thread. Problem is that my app still is not behaving the way I would like it
to...
It still hangs while the thread sleeps - the GUI is frozen and the screen is
unpainted.

What I want to happen is for the GUI to be independent of the actions in the
ThreadTask method. So do I need to create another Thread object and associate
it with my GUI?

Thanks in advance for any thoughts...

"Venkat_KL" wrote:
Hi dear Charles("hz****@nopost.com"),

Even though you know how to start a thread, I just give complete info

'First Imort the Threading Class
Imports System.Threading

'Declare a variable
Private trd As Thread

trd = New Thread(AddressOf ThreadTask)
trd.IsBackground = True
trd.Start()

Private Sub ThreadTask()
Thread.Sleep(100)

'do your media player stuff here

End Sub

Thats all.

for anything and everything, please reply back

bye
Venkat_KL

Oct 7 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that...
2
by: Jerry Sievers | last post by:
Fellow Pythonists; According to the docs +-----------------+ |interrupt_main(|)| +-----------------+ Raise a KeyboardInterrupt in the main thread. A subthread can use this function to...
7
by: Simon Harvey | last post by:
Hi everyone, I need to make a service that monitors a directory for changes in the files contained within it. I have two questions: 1. I'm going to be using a FileSystemWatcher object to do...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
3
by: hzgt9b | last post by:
Using VS 2003, VB .NET: Currently I have a windows app that I'm running in a single thread. Recent client requests have me interested in learning how to create another thread and perform an action...
12
by: Andrew Bullock | last post by:
Hi, I'm using a second thread within my program to do some long calculations, without locking up the UI: worker = new Thread(new ThreadStart(myClass.Run)); worker.Start(); I want to be...
5
by: Alan T | last post by:
I will do several things in my thread: Copy a file to a location Update database record Read the file content Write the content to a log file If I call Thread.Abort(), it may be possible to...
4
by: hzgt9b | last post by:
Using VS 2003, VB.NET and/or ASP.NET 2.0, BACKGROUND I have a window forms based application that contains a TreeView control and a WebBroswer (AxSHDocVw.AxWebBrowser) control. The TreeView is...
4
by: sherifffruitfly | last post by:
Hi all, I'm trying to to figure out this stuff, and I've got part of the trick in the code below, which updates a textbox with data from another thread. What I'd like to do is put a Pause button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.