What’s the difference between using a MessageManagerLock
vs MessageManager::callSync()
? Is the latter typically preferable?
callSync
doesn’t lock the message thread, it blocks the calling thread until the function has been called on the message thread. You should use it when you need something that must run on the message thread but is triggered by some other thread.
1 Like
I would recommend whenever it’s possible to use a asynchronous method and not these. Locking the message thread from a plugin can be dangerously, because you are not in full control of it, which can cause deadlocks. For example host tries to close the plugin from the message thread, while the plugin is waiting to get synchronous access to the message thread, freeze
2 Likes