As commented by @Lambie, in constructions like OP's while always means during [some extended period of time]. Although when is often used with exactly the same sense, it can also be used to mean at the same instant in time. Consider...
1: While I was watching TV, lightning struck the aerial.
2: When I was watching TV, lightning struck the aerial.
...where both while and when clearly both mean during (they both refer to the period of time that I was watching TV). But reversing the sequence to...
3: ?? While lightning struck the aerial, I was watching TV.
4: When lightning struck the aerial, I was watching TV.
...creates a real problem with #3. Since a lightning strike is instantaneous, you must assume I'm referring to an extended period of time during which the aerial was struck more than once - but how could I continue to watch TV after the first strike?
In practice the default assumption on hearing #3 would be that the speaker doesn't have very good command of English, but in other contexts the when/while distinction can be used perfectly naturally to convey different meanings.
5: When I hit him, the crowd cheered.
6: While I hit him, the crowd cheered.
The default assumption there would be that in #5 I only hit him once, whereas #6 refers to an extended beating. Note that it's at least possible for #5 to mean each time I hit him, but in practice I'd probably use whenever if that was what I meant.
Note that as is also used to mean while, during in some contexts, but because it can also mean since, because, it wouldn't usually be used in contexts like OP's example.
It's worth making a couple more points. Firstly, none of the commas in my examples are actually required. Secondly, it's perfectly possible to place while/when between the two clauses (replacing the comma). Doing this makes #3 and #4 semantically equivalent to #1 and #2 (When he arrived, I left means the same as I left when he arrived; we've just reversed the order of the clauses).