Ngay khi is used to emphasize that one action happens immediately after another. Vừa mới is often used to express actions that happened very recently or to emphasize that something has just been completed.