The message thread waits for a CriticalSection on a database. I have a second thread which is holding a lock on the database. The second thread wants to fail, hits an error, and calls showMessageBoxAsync which then gets into a deadlock.
- Don’t hold a lock when trying to display an error. This is a bit awkward - probably easy if I was using exceptions but requires a lot of rejigging stuff.
- Write a version of showMessageBoxAsync which is fire and forget and returns immediately eventually showing a message box.
But I don’t understand why showMessageBoxAsync is waiting for the message to be processed by the message thread before returning - seems the opposite of asynchronous…? It sits on callFunctionOnMessageThread … message->finished.wait() - this looks unnecessary?