This grammar means you do two things at once. You do a second thing because the first thing makes it easy to do.
、に。
I'll stop by the post office while I'm out for a walk.
、にに。
While visiting a friend in the hospital, I tried going to the new cafe that opened nearby.
、。
While I was out shopping for dinner, I wasn't able to find anything particularly interesting.
へ、。
While on my business trip to Kyoto, I plan to visit a few old temples.
、。
Let's take some pictures at a scenic spot while we're out for a drive.