When our thoughts are lost in worry in can be helpful to focus our mind on something else. Prayer is an excellent solution as it focuses our mind on God.
It focuses our mind on all the times that things worked out for the best.
It can be hard when your in the grips of worry to think about anything else but this is exactly when you will feel the biggest benefit.