By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,880 Members | 700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,880 IT Pros & Developers. It's quick & easy.

Would I be better off using a new thread for this?

P: 19

I have a sound file playing which lasts 50 seconds say. At 30 seconds, I need a new window to open and load a picture.

Would I be better off creating a new timer, when it hits 30 seconds, fire the new window or would I be better off creating a new thread, have the timer in the thread, fire at 30 seconds then kill the thread?

Or is there something I can just use in .NET which does this sort of thing (a special timer or something that latches onto the sound player.

I'm using the following to play the sound currently

Expand|Select|Wrap|Line Numbers
  1. [System.Runtime.InteropServices.DllImport("coredll.dll")]
  3. private static extern int PlaySound(byte[] szSound, int Mod, int flags);
  5. System.IO.Stream wav = _assembly.GetManifestResourceStream("h:\new.wav");
  7. Byte[] soundBytes = new Byte[wav.Length];
  9. wav.Read(soundBytes, 0, (int)wav.Length);
  11. int res=PlaySound(soundBytes, 0, 0x0005); //SND_MEMORY | SND_ASYNC

Jun 8 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 449
You should use a Timer instead of threads...
Start the timer as soon as you trigger the Play() function..

and give it an interval of 50 sec i.e. 50000 milliseconds as the timer interval.
Jun 9 '10 #2

Post your reply

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