Checking task has been created before calling wait