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

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

19
Hi,

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")]
  2.  
  3. private static extern int PlaySound(byte[] szSound, int Mod, int flags);
  4.  
  5. System.IO.Stream wav = _assembly.GetManifestResourceStream("h:\new.wav");
  6.  
  7. Byte[] soundBytes = new Byte[wav.Length];
  8.  
  9. wav.Read(soundBytes, 0, (int)wav.Length);
  10.  
  11. int res=PlaySound(soundBytes, 0, 0x0005); //SND_MEMORY | SND_ASYNC
  12.  
Thanks

Paul
Jun 8 '10 #1
1 1011
ThatThatGuy
449 Expert 256MB
@nodoid
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

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

Similar topics

2
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
2
by: Elizabeth Harmon | last post by:
Hi All I am just double checking myself here. I have two threads that i am running in an application, One Thread Updates a client side Table in a local DB, another Updates a Server Side Table...
3
by: Stephen Miller | last post by:
I have an ASP.Net application that sends a NetworkStream to a .Net Service, which has a TcpListener listening on a port for the ASP.Net client. When it receives a request it creates a new thread...
2
by: Evan | last post by:
I have an aspx page that can take a minute or so to load because it loads images from a database. I want to open a window and show a "Please Wait" message page at the start and close it when the...
2
by: monkeydragon | last post by:
Which is better, using ReadFile/WriteFile or use fstream?
1
by: batista | last post by:
Hello all, I have a third praty grid control...named C1grid. Im using it in one of my apps.. Now, I have bind this grid to a custom dataset class named "DataViewEx". The code of the class is...
10
by: gomzi | last post by:
Hi, I would like to know as to which method is better? Using session objects or cookies for storing information? Which one would be more reliable? And will there be any visible differences in...
3
by: sekarm | last post by:
Dear guys, In C# windows application i am using four threads for seperate process. Each thread done seperate job.i want to monitor the thread process in main windows form.so each...
0
by: ipramod | last post by:
Hi, I just wanted to calculate CPU Percentage Utilization in ASP.Net application using a thread. I have written following code: protected void Page_Load(object sender, EventArgs e) {...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.