間 says that two situations continue over the same span. Adding に makes the main event occur at some point within that span. The clauses may have different subjects.
Usage Notes
間( is used when two situations cover the same span of time, and 間(に when something happens at some point within that span. The に narrows the main event to a point or occurrence inside the larger period.
Related Grammar
Concurrent events with ながら
During with うちに
Used when referring to a period of time, especially when taking advantage of an opportunity.
While with うちは
Used when contrasting with another period of time.
Kyouko’s ribbon needs to be washed. Since she is a jiāngshī (vampire), she will uncontrollably attack people to drink their blood when her ribbon is removed. For this reason, her brother tries to tie her up with a rope. Kyouko hides in the bathroom, then sneaks out the window only to find Kenji waiting outside.
ケンジ:
「干(してる間(じっとしてればすぐ済(むだろ。」
“While it's drying, if you'd just keep still it'd be over soon.”
A murder victim was last heard from via phone call at 9PM. Her body was found outside later that night. Yukiko was in the main room with everyone except when she was bathing.
有希子(:
「私(が入(ってる間(、誰(か部屋(から出(た人(はいた?」
“While I was in the bath, was there anyone who left the room?”
Urushi prepared chocolate to give Ayumu for Valentine’s Day but is too nervous to give it to him. After the two play shogi during their club, Ayumu turns away from Urushi as he puts the shogi table away.
うるし:
「今(。歩(が 後(ろ向(いてる間(にかばんに入(れればいいじゃん!!」
“Now! While Ayumu's back is turned, I can put it into his satchel!”