AddUserInterfaceUpdate Question

If I had a list of items that were excluded from a thread because they updated the GUI could they be called in a method using AddUserInterfaceUpdate from inside the thread? I’m just thinking of doing this in bulk rather than individually.

These are the items:
#If Not DebugBuild Then
CycleDampers // This will update info in GUI also.
#EndIf
// Menu items
If HeatingEnabled Then
HeatingMode(1).Checked = True
HeatingMode(0).Checked = False
Else
HeatingMode(0).Checked = True
HeatingMode(1).Checked = False
End

HeatingSeason_Mode(HeatingSeason).Checked = True //Menu Item Checked
HeatSourceFuel(HeatSource).Checked = True //Menu Item Checked
DHWMode(DHWTankMode).Checked = True //Menu Item Checked
Watering(WateringSystemEnable).Checked = True // Menu Item Checked

The UserInterfaceUpdate event runs in the main thread. Any long-running code will block the UI. Keep your code in UserInterfaceUpdate short.

Hmm. My thread is associated with in a splash screen window and the UI that is being updated is in another window that will show after the thread has finished its chores. Does that make a difference? I’m trying to finish all the prep work while the splash screen is splashing before opening the main window. The GUI stuff is the only thing being left out of the thread at this point.

If the other window isn’t visible while the thread is running, why don’t you populate a set of properties somewhere that the window can use in it’s Open event to initialize its control’s values. Skip UserInterfaceUpdate entirely.

1 Like

As I think about it, the only reason I created the thread that did the heavy lifting before the main screen opened was that I could not keep a progress bar moving in the splash screen while loading data in the main threads main screen, hence another thread. Frivolous, but it is all about keeping a progress bar moving in the splash screen while loading data.

I guess I was looking for an opportunity to better understand how to use AddUserInterfaceUpdate which may not make sense in my application.

It does make sense, but the code you put in AddUserInterfaceUpdate could be simply for updating the progress bar.

If you thing the data that the thread is generating will cause the next window to take a long time to display, you could do that work too, but it not, I’d just do that at the end.