Fix deadlock when waiting for a resource that is background loading but is now needed immediately.