单项选择题

It was not until he entered the classroom ______ he realized that he had forgotten to do the homework.

A. before
B. when
C. then
D. that