The problem is when I enter a new brightness value, XOJO triggers this event three times for some reason and crashes with an exception on the third round.
I’ve got around it with a flag that stops executing the repeat and is reset when the cursor once again enters the ComboBox:
If flag = False Then
SDConnection.send(“Get”, “http://” + S_Address.value + “/Light/”+Channel.value+"?brightness="+ Me.value)
Flag =True
End
This feels like a patch to me that could be avoided. Ideas?
I use a timer that is started each time the change event fires. The timer waits a second or 2, in case the user is not finished typing. Put your code in the timer event.
Good suggestion but after reading the notes about sendsync I decided to go with the flag but place the flag reset in the URLConnection.ContentRecieved:
Be aware that calling SendSync can cause your app’s UI to “freeze” while it waits for the result. For normal processing you may want to use the asynchronous Send method instead.
Feels a little cleaner now and seems to work fine. Thanks to all of you for the direction on the cause of the exception. It got me thinking about the multiple events.