Hadith 1061
Abu Hurairah (May Allah be pleased with him) reported:
وعن أبي هريرة رضي الله عنه أن رسول الله صلى الله عليه وسلم قال: "لا يزال أحدكم في صلاة مادامت الصلاة تحبسه لا يمنعه أن ينقلب إلى أهله إلا الصلاة" ((متفق عليه))
The Messenger of Allah (ﷺ) said, "Everyone among you will be deemed to be occupied in Salat (prayer) constantly so long as Salat (the prayer) detains him (from worldly concerns), and nothing prevents him from returning to his family but Salat." [Al-Bukhari and Muslim].
In plain words
As long as the prayer is what keeps you waiting, you are counted as being in prayer the whole time, so waiting for it is itself rewarded.
Reference : Riyad as-Salihin 1061 In-book reference : Book 8, Hadith 71