You could set a flag (just simple boolean variable) which has an initial value of false. When your code is going to refresh the frame, check this flag, and if it is false, set it to true and then refresh the frame. Then when the routine fires again, your flag is true, no second refresh is done, and that should fix the problem.