overtime_e
December 27th, 2004, 01:25 PM
Hello everyone,
i have a problem with multithread programming.. my program needs to play a wav file when a variable reaches a certain value.. i have used multithreading to play the wav file.. my aim is to make the program plays the wav file while it is still executing other events..
my problem is: the wav file only starts to play at the end of the program though the i have instructed it to start earlier..
skeleton of my code:
int main(void)
{
... //some codes
while ( ... )
{
...
...
Count = Count + 1; // Count = 0 initially
if (Count == 20)
{
_beginthread(PlayingWav, 0, NULL);
}
...
...
}
... //last line of codes
}
//PlayingWav function
void PlayingWav(void *dummy)
{
PlaySound("D:\\Temp\\song.wav", 0, SND_SYNC | SND_FILENAME);
}
everything runs smoothly but the song.wav is only played at the last line of my program.. can somebody tell me why? thanks thanks
i have a problem with multithread programming.. my program needs to play a wav file when a variable reaches a certain value.. i have used multithreading to play the wav file.. my aim is to make the program plays the wav file while it is still executing other events..
my problem is: the wav file only starts to play at the end of the program though the i have instructed it to start earlier..
skeleton of my code:
int main(void)
{
... //some codes
while ( ... )
{
...
...
Count = Count + 1; // Count = 0 initially
if (Count == 20)
{
_beginthread(PlayingWav, 0, NULL);
}
...
...
}
... //last line of codes
}
//PlayingWav function
void PlayingWav(void *dummy)
{
PlaySound("D:\\Temp\\song.wav", 0, SND_SYNC | SND_FILENAME);
}
everything runs smoothly but the song.wav is only played at the last line of my program.. can somebody tell me why? thanks thanks