Hi,
I’m trying to run a plugin in a console app so I need the MessageManager to be ready when I’m scanning it.
On windows this works:
MessageManager::getInstance()->callAsync ([&app] () {
app.run();
});
MessageManager::getInstance()->runDispatchLoop();
On mac, runDispatchLoop() returns immediately and callAsync is never calling app.run();
I’ve tried enabling JUCE_MODAL_LOOPS_PERMITTED, but it still doesn’t work.
Anybody can help me understand what is happening here? Thanks!
Ok, here’s the solution. Some extra code is needed in a Mac:
#if JUCE_MAC
namespace juce {
extern void initialiseNSApplication();
}
#endif
int main (int argc, char* argv[])
{
#if JUCE_MAC
initialiseNSApplication();
#endif
MessageManager::getInstance()->callAsync ([&app] () {
app.run();
});
MessageManager::getInstance()->runDispatchLoop();
yfede
March 20, 2023, 9:20am
3
I may be misunderstanding the purpose of your code, but if all you need is make sure that a part of your code is called on the message thread, wait for its completion, then move along on whatever thread you already were, you could make use of callFunctionOnMessageThread()
1 Like