Used when something happens while you are busy doing this and that; often implies a passage of time during miscellaneous activities.
See also: そうこう · そうこうしているうちに
In the meantime, it got completely dark.
While I was doing this and that, the train time arrived.