What I have found very help is keeping a log of everything that I am doing on a single task. So ever 15 minutes or so, I just write done a small paragraph or even a sentence of what is going on for a particular task. I find that doing this really helps me get back on track if I am disturbed or have to focus on something else for a short while.