Replacement for runDispatchLoopUntil()?

Maybe @dave96 or @g-mon can answer that. They know at least the tracktion part.

It might be a good idea to change the category to #tracktion-engine or create a new topic in that category.

Thank you. I will probably do that after trying a few more things.

It is frustrating because it works just fine as a modal dialog, and has been for a couple of years. But I am refactoring my code to remove modal loops and this is one of the last ones to figure out.

I appreciate everyone’s suggestions!

I imagine the ThreadPoolJobWithProgress is getting deleted when the runTaskWithProgressBar function returns?

Do you have to make this non-modal now?
I appreciate modal loops are bad and we should not be using them in new code but this codebase has relied on them for 20 years so it’s not simple to just remove them. We’ll probably need to add alternative methods that request a task to be started and provide a callback to be notified when it ends.

There might be some way to hack it in the mean time but I don’t really have the bandwidth to look in to it right now I’m afraid.

I can compile with the preprocessor value JUCE_MODAL_LOOPS_PERMITTED = 1 for the time being. I was just trying to be up-to-date.

As always, thank you for your help!

I’m also stuck with this problem for different reasons - unit testing.

TEST_CASE("Testing async calls")
    juce::ScopedJuceInitialiser_GUI gui;
    int x = 0;
    juce::MessageManager::callAsync([&x = x] { x = 3; });

    //This following section used to be:

    //I tried to replace it with:
    while(x == 0)
        //But, that loop never ends...

    REQUIRE(x == 3);

Any ideas?

My understanding is that there is no simple way to achieve the functionality of juce::MessageManager::getInstance()->runDispatchLoopUntil(1);, so you must use that, along with the JUCE_MODAL_LOOPS_PERMITTED = 1 flag for the time being.

1 Like

Thank you!
Hopefully that gets fixed one day so I can also turn the modal loops off. :slight_smile: