Slider PositionChanged gets called twice

I have a problem when using a slider.

If I update the slider in the normal way i.e. touch it then the event When "Slider1.PositionChanged" gets called once as expected.

If however I set the Slider position using Set Slider1.ThumbPosition to a value then the event "When Slider1.PositionChanged" gets called twice.

The problem is that when the Slider gets changed I send one Bluetooth message and not two!

I have attached a couple of screen shots of a very basic example.

Ian James

Set a boolean type variable with the button click, then test for this in the PositionChanged event (resetting the boolean afterwards!)

Try this:

I like a repeating Clock Timer and a global LastThumbSent (init 0) for this.

In the PositionChanged event, don't bother doing anything.

In the Clock.Timer event, 
check if Slider1.ThumbPosition does not equal LastThumbSent .
If unequal, then
  set LastThumbSent to ThumbPosition
  send the LastThumbSent value
  do nothing.

Set the Clock Timer milliseconds to whatever value that equals your patience level, without overwhelming the other end of your BlueTooth link.

1 Like