The correct option is B when
When a story is told in the past tense, the adverbials hardly, scarcely, barely and no sooner are often used to emphasize that one event quickly followed another. The verb describing the earlier event is usually in thepast perfect tense. If hardly, scarcely, barely and no sooner are in the initial position, the subject and auxiliary are inverted.
Note that hardly, scarcely and barely are followed by when, while no sooner is followed by than.
Than provides a form of contrast between two events.
When is obviously related to time.
Hence, Option C - 'when' is correct, and the other options cancel out.