The differences between 'when' and 'while'?

As my title, could anyone tell me the differences between ‘when’ and ‘while’? Thank you.

We usually use while to say that two longer actions or situations go/went of at the same time: While you were reading the paper, I was working.
We prefer when to refer to ages and periods of life: When I was a child we lived in London.
You can add as to this list of words. As is used to talk about two situations which develop or change together: As I get older I get more optimistic.
We can use all three words to introduce a longer ‘background’ action or situation, which is/was going on when something else happens/happened:
As I was walking down the street I saw Joe driving a Porsche.
The telephone always rings when you are having a bath.
While they were playing cards, somebody broke into the house.

From ‘Practical English Usage’ by Michael Swan: When/While/As
(Sorry, but I don’t have the book now, if there’s something wrong please help correct it, thanks very much.)

1.background situation
When/While/As I was walking down the street, I saw Peter drive a Volvo passing by.

2.a period time (usually progressive form)using while/when
While/When I was playing cards, Davied came in.

3.two acting, two continual one (two progressive forms)
While I was having dinner, Mom was watching TV.

4.two simple tense while/when either can be used, yet if what we talk about is about the age or kinda life step, usually using ‘when’
I had lunch in the restaurant while/when she studied in the library.
Mary’s mother died when she was 12. (speaking of the age)
Mary married a cute guy when she was in London. (speaking of a kind of life step)