When (A) ている
is paired with 間（あいだ）に
(B), it expresses that ‘(B) is happening/happened within the timeframe of (A)’. These events do not need to be related in any specific way, but the (B) action must happen somewhere within the duration of (A). This construction translates naturally as ‘during the time that (A), (B)’.
Hey, don't talk to me while I'm counting.
I tripped and hurt myself when I was carrying luggage.
will often be used when the (B) action is somehow beyond the control of the speaker. However, this is not always the case.
間（あいだ） literally means an ‘interval’, and therefore highlights the (A) event as being the ‘whole’ span of time, within which (B) happened/will happen at some point.