Introduce and use wait_for_search_finished()