Shouldn't the initialiseJuce_GUI() create a thread and run the dispatch loop?


I’m writing a dynamic library using JUCE, but after I called the initialiseJuce_GUI(), I found that I still can’t receive callbacks like the “timerCallback” that rely on the system message queue.

after digging into the JUCE source code, I found that I must create a thread, and run the MessageManager’s dispatch loop manually after calling initialiseJuce_GUI().

My question is, shouldn’t it be the responsibility of the JUCE library to automatically create a thread to run the dispatch loop at initialization time?

Shouldn’t there be a class like “MessageThread”, or something like “MessageManager::createMessageThread()”, or create a thread to run the dispatch loop straightly in the “initialiseJuce_GUI()” in a non JUCE GUI build?

If you don’t think it’s a good idea to do so, then why not?


I think it’s more standard that whatever is hosting the dynamic library creates the message thread. You definitely don’t want two message threads per application, so juce should create it automatically. In your case, I guess the host application doesn’t have a UI. I imaging that this is the more unusual case, therefore you need to handle it yourself.