How to use As, when and while
As, when and while are conjunctions. In some uses as, when and while can mean the same, but they can also have slightly different meanings. We use them to introduce subordinate clauses.
We can use as, when and while to mean ‘during the time that’, to connect two events happening at the same time:
He arrived as we were leaving.
We often use them with the past continuous to refer to background events:
The telephone always rings when you are having a bath.
While they were playing cards, somebody broke into the house.
While he was working, he often listened to music.
We can put clauses with as, when and while before or after the main clause. When they come before the main clause, we use a comma:
As we were leaving the court, a crowd of photographers gathered around us. (before the main clause, followed by a comma)
The telephone always rings when you are having a bath.
Lucy came into the room while he was waiting.
As
We can use as to introduce two events happening at the same time.
After as, we can use a simple or continuous form of the verb.
The continuous form emphasizes an action that interrupts or occurs during the progress of another action:
As she walked to the door, she thanked them for a lovely dinner.
As they were signing the contract, they noticed that a page was missing.
As I was watching television, the light went off.
When
We can use when to introduce a single completed event that takes place in the middle of a longer activity or event. In these cases, we usually use a continuous verb in the main clause to describe the background event:
He was walking back to his flat when he heard an explosion.
Depending on the context, when can mean ‘after’ or ‘at the same time’.
Compare
When you open the file, check the second page.
when meaning ‘after’
I eat ice cream when I am on holiday.
when meaning ‘at the same time’
We often use just with when or as to express things happening at exactly the same time:
The phone always rings just when I’m closing the front door.
She was a brilliant gymnast, but she had a terrible accident in 1999, just as her career was taking off.
While and as
We can use while or as to talk about two longer events or activities happening at the same time. We can use either simple or continuous verb forms:
We spent long evenings talking in my sitting-room while he played the music he had chosen and explained his ideas.
We were lying on the beach sunbathing as they were playing volleyball.
As and while can be used with a simple tense, especially with a 'state' verb like sit, lie, or grow.
As I sat reading the paper, the door burst open.
We usually use while to say that two longer actions or situations go/went on at the same time. We can use progressive or simple tenses.
While you were reading the paper, I was working.
John cooked supper while I watched TV.
As is used (with simple tenses) to talk about two situations which develop or change together.
As I get older I get more optimistic.
We prefer when to refer to ages and periods of life.
When I was a child we lived in London. (NOT As While I was a childt...)
His parents died when he was twelve. (NOT ... While he was twelve.)
Reduced clauses with when and while
It is often possible to leave out subject + be after when (especially when it means 'whenever'), and after while. This is rather formal. Don't forget to signal when turning right.
(= ... when you are turning right.) Climb when ready.
(= ... when you are ready.) While in Germany, he got to know a family of musicians.
(= While he was ...)
He read his book while waiting for the bus. (while he was waiting)          
Warning:
We can’t use as in this way:
We ate our sandwiches as we walked around the park.
Not: … as walking around the park.