The only differences are the obvious changes of "while" and "when" and the position changes of the two clauses. Other than those superficial changes, the meaning remains the same in all. Only the last one seems somewhat unidiomatic to me, but I don't see any serious objection even to that one.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.