This grammar shows that something happens exactly when another thing is happening. It means 'just as' or 'right when'. The second event often surprises you.
、。
A friend showed up right when I was in the middle of cooking.
、。
It's really disappointing when I get interrupted while listening to good music.
、。
Just as I was leaving the house, a call came from my mother.
、。
It was sad that when I was in trouble, no one helped me.
、。
The new employee who interrupted just as the department head was saying something important was reprimanded later.