Fix bug related to waitAllTaskComplete