How to update user interface from a callback function

Hello,

I’m working on a class plugin based on an open source library. This library implements the possibility to callback a function returning some parameters. I use this parameters to update controls. Calling a shared method of Xojo works fine but I don’t see how I could periodically update the controls without using the very unliked App.DoEvents. I did some tests with Thread without success.

Does someone could give me some lights. I’m completely stuck.

Thanks

Be a rebel :slight_smile: - use App.DoEvents().

Or, if you’re interested in a safer mechanism and threading, use a one-shot timer that you fire from the thread. You can create the Timer in code:

Add tmShowStandabyTimer to your window’s properties

In the window Constructor, add:

tmShowStandbySheet = New Timer tmShowStandbySheet.Mode = 0 tmShowStandbySheet.Period = 1 AddHandler tmShowStandbySheet.Action, AddressOf ShowStandbySheet
Create a Method named “ShowStandbySheet(Sender As Timer)” and add your UI update code calls

In the Thread, when you need to update the UI, fire the Timer by setting its mode to 1:

tmShowStandabyTimer.Mode = 1

Tim,

Thanks for the advice. In fact this is the former method used to update UI from a thread ? I also gave a try with the new one (AddUserInterfaceUpdate-UserInterfaceUpdate) unsuccessfully. The main issue is that shared methods cannot access instance properties. From my knowledge I have no choice but to use a shared method if I want to be called back from the plugin.