There is a long thread (four pages) on "when and while". Start here: when/while/as In short, "while" is more usual in the case you show in your post, but "when" is also possible. CJ [2]
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.