It's pretty much pointless to try to "fix" anything without seeing the code, but I can give you one idea.
There are cases when you really can expect different behavior when you execute code step-by-step or use break points, under the debugger. Why? For example, because such factor as timing can be important. But if you don't expect such effect, the mere fact that you have different results under the debugger is a clear indication of incorrectness of your code. One probably explanation is the same very timing, incorrect dependency on the time of execution, which can be revealed in case of any kind of parallelism. Such phenomena are known under the name "race condition":
http://en.wikipedia.org/wiki/Race_condition[
^].
This is the fist thing to think about.
—SA