WPF Slider control Delay issue??
I've been trying to control the master volume of windows for a while using WPF. I worked from this example: http://www.codeproject.com/KB/vista/CoreAudio.aspx
Everything in that example works 100% when it's a WinForms app and at first all seemed well in WPF also after I changed all the value types to floats. But then I found that if I move the slider somewhat quick it goes into some sort of infinite loop.
Theory 1:
When you move the slider, it changes the system master volume. If you change the system master volume, the slider updates with that. So what I think is happening is that the slider tell the system to be X, but as soon as you do that the system tells the slider to Y and then the slider control's ValueChanged event gets fired the whole time and it keeps switching between the two values. I'm not a 100% sure if that exactly whats happening as it doesn't really make sens, but I think it's something like that.
The control works fine if you move the slider slowly, but as soon as you
move it quick it goes into this loop.
Theory 2:
Another theory is that the value that the slider is sending to the system is either larger or smaller than what the system is returning. So when you change the slider, it's updated the system, the system changed event triggers, the system then updates the slider, but with a different value, slider's changed event is fired, and so the loop continues. This also doesn't really make a whole lot of sens.
Theory 3:
One more theory is that there is a delay between the slider's value change and the system updating the value. IOW, by the time the slider is at 12, the system is still updating to 10 and as soon as that happens it goes into this loop somehow as the ui wants to be X, but the system wants it to be Y and thus the loop. I just realised that it might actually get stuck in the ValueChanged event of the slider. So before the event has finished, the system tries to make it's value something else?
So now I'm am stuck. I've only recently started playing around with WPF, so maybe I might be doing something wrong? The exact same code works perfectly in a WinForms app which you can test with the Sample app in the CodeProject link I posted. Also, if I try and google for other examples I keep getting linked back to the CodeProject app as someone replied with that link and then that tends to be the end of the topic.
I'm working with C#, WPF, .NET 4.0 and VS 2010 Express
Regards