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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Hi dear Charles("(e-mail address removed)"),

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
 
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.
 
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...
 
Back
Top