They are interchangeabe when both used to refer to something that happens at the same time or during the time that something is happening. Her parents died when/while she was still at school. ' While ' can be used to contrast two things.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.