when和while怎么用?

问题描述:

when和while怎么用?
比如Somebody stole my bag.I was talking to my friend.

Somebody stole my bag when I was talking to my friend.while呢?