The refresh job checks dirs (time consuming) and in the same loop updates the menu (blocks UI). If these two tasks are separated the UI would not block.
The check dirs could be run periodically and save to state, (this can be a dispatched function)
The create-menu-function reads state and creates menu (this will be fast)
somehow the refresh jobs must be done in the background without blocking the UI.