I am a christian so can only comment on my own experience (but I believe that the Allah muslims seek to know is the same god that I worship as a christian...)
Anyway when I was reading your post I was reminded of someones experience recently - that god had answered their prayers, but very much in HIS way, and very very much at the last minute. And I remember when we were discussing this, others who were with us, saying they had also found that sometimes god has this habit of answering your prayers - but not until the absolute last minute, when you may have given up all hope!
Why does he do it that way? I dont know - and if you ask me, there probably isn't one answer anyway - as I believe that god is very much individual to each and every one of us, therefore the reason he may not answer your prayers, or may answer them but not till the last minute, might be totally different from the reason he might do the same thing with someone else..... Its all about the fact that God knows us far far better than we can ever know ourselves - and it may be that his plan requires something to happen differently from the way we think it should - and later on we will look back on that experience and say ' if it hadnt happened that way - I would not have learnt this, or gained this, or met this person', or whatever.
But of course that sometimes does not help you at the time.
The other thing to consider - I am not sure what the Muslim view point is on this, but the christian one is that god is VERY big on freedom of choice. And as we all know - what we choose to do or not do has consequences. And maybe sometimes there are situations that cause you pain and suffering. And that is not because god is not aware of your pain, or doesnt care, but because some other person on this earth, (and by person I don't mean someone you necessarily know personally - it could be your government, or another government - or it could be a friend or family or anyone). But the point is, that if some other people have made a choice to do something which might cause harm, then sometimes god has to allow them to suffer the consequences, and as part of that - it might be that you are suffering the consequences
So if your current situation is caused by the actions of other people (whether you know them personally or not) then consider that god may be watching and grieving for what you are going through, but as a completely 100% just, and fair god who wishes only to have a geniune relationship with his people - ie a relationship they 100% freely choose - that he has to allow them to make their own choices and mistakes and sometimes that means innocent people get hurt.
Another reason I personally feel that god sometimes allows bad things to happen, is because his plan for you is to use you to help many other people in similar situations. And if that is the case at some time in the future you may find yourself in a place where you can help other people who are going through similar things. And at that time, you might find that other people try and advise and help those people, but cant break through - but you can because you have been in the same situation yourself. And at that point you might look back on what is happening now and think "If I had not been through that terrible time, I would not be able to really connect with this person that god wants me to help now" So your suffering could actually be god purifying and training and strengthening you for a greater purpose that you are not yet aware of.....
Another reason I personally think god has allowed some things to happen in my life - is to remind me that I need to always look to him and depend on him. When all is going well in our life it is very easy to forget god. Sure we pray to god, and praise him and thank him - but we dont have the same desperate yearning for his help that we do when we are in times of trouble. My own personal experience since becoming a christian and getting to know god personally - has been that the times in my life when everything is going wrong, and it is all terrible, have also been the times when I have most intensely felt gods presence, and just felt sure that god had his hand over whatever was going on and it was in his plan and it would all work out eventually (but not necessarily the way I expected or wanted) I think god uses these times to draw us closer to him, and to teach us and help us grow into the people he has made us to be. And when you look at things that way, and take time to just share all your feelings with god about the situation, you might find that you come to a point where in amongst all your troubles, you aware that something very precious and intimate is going on - as a direct result of gods great and personal love and passion for you.....
In terms of practical advice - if you have been praying for a specific solution to your problems - maybe try a different approach - such as asking god - is the solution you want in his plan - and if not can he help you accept that, and show you what is in his plan. Maybe if instead of focusing only on whether the answer you expect happens or not, you try - difficult as it is when you have problems weighing on you - to just ask god to comfort you, and say something like - if fixing this for me is not in your plan, please help me to accept that, and please uplift and comfort me, and give me the strength to endure my troubles if they are in your plan, and teach me all I need to learn from this.
Another thing you can do is if you have been - praying to god to fix it but at the same time (as we all usually do) trying to figure out what YOU should do, and feeling as though You have to make the right move and if you make the wrong move things will go wrong, you can just say "God/Allah I give up, i dont know what to do, or why this is happening, I dont feel able to manage it or cope, I surrender this entire situation to you, to deal with according to your will. I cant endure this, or manage this on my own, please help me - show me what your will is here, and help me obey it, even when I may not want to....and understand it, when I dont.."