The followings are explanations and teaching aids from learn english and British Council~~
圖片參考:
http://hk.yimg.com/i/icon/16/8.gif
Adverbs
When and While
Both when and while can be used to talk about actions or situations that take place at the same time.
1 Backgrounds
We can use both words to introduce a longer 'background' action or situation, which is/was going on when something else happens/happened.
Somebody broke into the house when they were playing cards. While they were playing cards, somebody broke into the house. Note that when and while clauses can go at the beginning or end of sentences.
2 Simultaneous long actions
We usually use while to say that two longer actions or situations go / went on at the same time.
While you were reading the paper, I was working. If we are talking about ages and periods of life, we use when:
When I was a child we lived in London (NOT While I was a child …) His parents died when he was twelve (NOT … while he was twelve) 3 Simultaneous short actions
We can use (just) when to say that two short actions or events happen / happened at the same time:
I thought of it (just) when you opened your mouth. While is not possible in this situation.
4 Reduced clauses
It is often possible to leave out subject + be after when and while:
While/When in Germany, he got to know a family of musicians. (=While/When he was in Germany …)
http://www.learnenglish.org.uk/grammar/archive/whenwhile01.html
===========================================
What is the difference between when and while?
Both when and while can be used to talk about actions or situations that take place at the same time.
Swan identifies the following differences:
1 Backgrounds
We can use both words to introduce a longer 'background' action or situation, which is/was going on when something else happens/happened.
圖片參考:
http://www.britishcouncil.org/spacer.gif
While they were playing cards, somebody broke into the house. Note that when and while clauses can go at the beginning or end of sentences.
2 Simultaneous long actions
We usually use while to say that two longer actions or situations go / went on at the same time.
圖片參考:
http://www.britishcouncil.org/spacer.gif
While you were reading the paper, I was working. If we are talking about ages and periods of life, we use when:
圖片參考:
http://www.britishcouncil.org/spacer.gif
His parents died when he was twelve (NOT … while he was twelve) 3 Simultaneous short actions
We can use (just) when to say that two short actions or events happen / happened at the same time:
圖片參考:
http://www.britishcouncil.org/spacer.gif
I thought of it (just) when you opened your mouth. While is not possible in this situation.
4 Reduced clauses
It is often possible to leave out subject + be after when and while:
圖片參考:
http://www.britishcouncil.org/spacer.gif
While/When in Germany, he got to know a family of musicians. (=While/When he was in Germany …)
http://www.britishcouncil.org/learnenglish-central-grammar-adverb-when-and-while.htm