You can’t call job.runJob() on the main thread, or your UI will not respond, as you are seeing. You need spawn a thread which calls job.runJob() in a loop.
Then runTaskWithProgressBar needs to wait until the thread is finished while pumping message loop.
Rough code to implement:
void runTaskWithProgressBar (ThreadPoolJobWithProgress& t)
{
TaskRunner runner (t);
while (runner.isThreadRunning())
if (! MessageManager::getInstance()->runDispatchLoopUntil (10))
break;
}
//==============================================================================
struct TaskRunner : public Thread
{
TaskRunner (ThreadPoolJobWithProgress& t) : Thread (t->getJobName()), task (*t)
{
startThread (4);
}
~TaskRunner()
{
task.signalJobShouldExit();
waitForThreadToExit (10000);
}
void run() override
{
while (! threadShouldExit())
if (task.runJob() == ThreadPoolJob::jobHasFinished)
break;
}
ThreadPoolJobWithProgress& task;
};
You’ll need to add whatever updates your UI.
