Hello dear All,

Now I'm writing an app that have to react on some user's actions in real time and redraw a big form according to this activity and a timer's firing. Also, when redrawing the form, the app must emit some short sounds. For the last purpose I used SoundPlayer class with its method Play(), that (due to the MSDN) must play a sound asynchronously. But the result seems as if SoundPlayer plays its sound just synchronously instead, so the user interface isn't updated until the sound is over. After numerous anguished experiments I have found out that the behavior depends on the form's DoubleBuffered property, and if I turn off double buffering, the problem disappears. But (as expected) then a problem of form flickering has appeared. So it seems that facilitation of graphic performance affects negatively sound performance, and vice versa. Possibly it because both double buffering and async sound playing apply to the thread pool simultaneously, that deteriorates general performance. But actually the form redrawing is a rather quick operation, and if I could wait the form being completely redrawn and then play sound it would be cool. Problem is that I haven't found any way how can I organize such waiting in my code. Does anybody have an idea about?

I'd personally just search for a better audio lib, or you could put the audio player in another thread and just call it from there.

I'd personally just search for a better audio lib, or you could put the audio player in another thread and just call it from there.

I tried not just to run the player in another thread but even in another application - a form outside of the screen bounds receiving commands to play sound via windows messages - and it was of no help, the problem still persisted.
Actually, I've already got a good tip - just to use Refresh() instead of Invalidate(), and it seems that it works. But anyway, thanks a lot!

if you just need to play 1 sound at a time try http://www.daniweb.com/code/snippet253704.html

i posted this snippet a while back, its async and works great, but if you play another sound it will stop the first sound. so just one sound at a time.

Thanks for your reply and the reference. But, returning to my problem, I've tried plenty of tricks, and using PlaySound from WinAPI was among the firsts. Alas, it didn't help.
By the way, I found incidentally that if I run some sound player (say, Winamp) and play a file with it, and then pause, my app works perfectly. Maybe it's because Winamp in this state keeps the sound device opened. I planned for myself to try to do the same way, but only if everything else dosn't help.

Try irrKlang sounds engine, its free for non-commercial apps. and fairly cheep for commercial ones. It does wonders and I have used it with doublebuffering plenty of times.

I'm think your problem might have to do with the system you are using or maybe some other part of the code as a asych call the the windows sound api shouldn't block your thread regardless.

but irrklang should work.

Try irrKlang sounds engine, its free for non-commercial apps. and fairly cheep for commercial ones. It does wonders and I have used it with doublebuffering plenty of times.

I'm think your problem might have to do with the system you are using or maybe some other part of the code as a asych call the the windows sound api shouldn't block your thread regardless.

but irrklang should work.

I've already solved the problem. But irrKlang will be of some use anyway, thanks.

This question has already been answered. Start a new discussion instead.