In the days of King Herod of Judea, there was a priest of Abijah’s division named Zechariah. His wife was... Elizabeth. Both were righteous in God’s sight, living without blame according to all the commands and requirements of the Lord. But they had no children because Elizabeth could not conceive, and both of them were well along in years...
An angel of the Lord appeared to him, standing to the right of the altar of incense. When Zechariah saw him, he was terrified and overcome with fear. But the angel said to him: “Do not be afraid, Zechariah, because your prayer has been heard. Your wife Elizabeth will bear you a son, and you will name him John. There will be joy and delight for you, and many will rejoice at his birth."
Luke 1:5-7, 11-14
If you have kids or are around them at all, you've probably noticed that they don't take no for an answer. When they want something they'll ask and ask and ask again. Even when you succeed in getting them to stop asking you today, chances are it'll be the first thing out of their mouths tomorrow. Although this behavior might be frowned upon from a parent's perspective, God actually encourages it. Repeatedly Scripture implores us to persevere in prayer, to keep asking God for what we need even when He doesn't answer right away (Luke 18:1-8, Romans 12:12, Ephesians 6:18). Zechariah's story reminds us of this.
As Zechariah prayed for a child I imagine he took comfort in Proverbs 15:29, "The Lord is far from the wicked, but he hears the prayer of the righteous." He and his wife were righteous people. Surely God would hear their prayer. But God never answered. Months turned into years and still he prayed. Zechariah prayed until he and Elizabeth had passed the age of childbearing. And then he stopped praying convinced that it simply wasn't God's will for his life. (I know I've taken some liberties filling in the biblical narrative here but I think there is reason to believe this is likely how it went.)
Then one day Zechariah was chosen to burn incense in the temple. This was likely a once in a lifetime opportunity, a big day in his life, but Zechariah had no idea just how big. As he stood alone in the temple praying and offering incense on the altar just outside the Holy of Holies, the angel Gabriel suddenly appeared to him. Gabriel had a message from God. Zechariah's prayer had been heard, he would have a son. His son would be the forerunner to the Messiah and the first prophet in over 400 years. His son would be John the Baptist. Zechariah was incredulous. He had a hard time believing that God had finally answered his prayer that he and his wife would have a child at their age. (This is one of the reasons I believe the prayer Gabriel is answering was likely uttered years before and not right in that moment.)
Be encouraged by this! God hears your prayers even when He doesn't answer them right away. Keep praying. Keep asking. Don't give up! He delayed in answering Zechariah's prayer so that when He did answer it would be all the more sweet to Zechariah and it would result in even more glory for Himself. God loves to answer the prayers of His children. Rest assured, if He isn't answering your prayer, there's a reason. God orders the events of our lives towards His ends. Trust Him and keep on praying.