I have some code (triggered by events in the processing thread) that I would like to execute in the same thread where the UI is running (that would be the “message loop” in JUCE right?). I wonder what would be the most elegant way to do it. First thing I can think of would be setting setup a FIFO queue with parameters of execution and empty it from a timer callback in the UI but this would introduce a latency (the timer’s period). Anybody can think of another way to do it that would interrupt the UI thread (would an instance of Thread class with a certain priority do that)? Ideally I would like to avoid interrupting the UI thread in some parts of the UI code that I would lock. Any ideas are welcome. Thanks!
I am literally just now doing this in my program, using a FIFO as you say :)
I use AsyncUpdater, with triggerAsyncUpdate etc.
I don't know how much latency it introduces, but as long as the only thing that depends on it is the GUI rendering in my understanding it is not perceptible.
If the loading of the preset is done in your working thread, the GUI really should have nothing to do with delaying the operation, only the loading from disk, which, if anything, is much slower than any GUI redrawing you might be doing anyway...
I don't see why the GUI should be involved in any of the loading, when all is done you have it reflect the changes to your model...
As for your description of the multithreading locking going on really I didn't understand a thing :D
When I had to do this I created these threads which were of great help to me, mayble they'll be also to you: