Added execute_on_main_thread function that can be used to ensure a
function executes on the main thread