Then look at it. Don't try to think positive. Don't try to look on the bright side, at least not immediately after a setback. It's too much of a jump. First find out what's wrong with your pessimistic thinking.
Most pessimistic thoughts are wrong.
The thought is wrong. It's even more of a mistake when you realize that you are less likely to survive thinking that way. If you would like to be more optimistic, practice arguing with your less optimistic thoughts. You are most likely to think them right after you hit a setback. When you feel defeated, or when something doesn't turn out the way you hope or expect, write down what you're thinking, and then look at it and see if anything is wrong with what you're thinking.