Hazrat Shaikh Moulana Muhammad Zakariyya (rahmatullahi ‘alaih) writes:
Dua is indeed very important, and to neglect making dua is a means of great loss and deprivation. Even when it outwardly seems as if our dua is not being answered, we should not lose courage and hope. It is reported in the Hadith that, in answering our duas, Allah Ta’ala looks at our own good and welfare. If the thing we ask for is beneficial and good for us, Allah Ta’ala grants it to us. If the thing we ask for is not beneficial and good for us, Allah Ta’ala does not grant it to us. Actually, it is Allah Ta’ala's favour upon us that we do not always get what we ask for, because at times, due to our lack of understanding, we beg for things that are not beneficial for us. (Fazaail-e-A’amaal [urdu], Fazaail-e-Ramadhaan pg. 22)