Fix potential deadlock

In case invoke is called from the dispatcher's thread