Graphics drawing loops commonly look like this:
The VSYNC stops the image from flickering, but if the graphics code takes longer than 1 frame, the VSYNC will do nothing and it will flicker.
Here is a solution:
WENDThis makes the program display one page, and edit another. After it finishes drawing the graphics for one loop, it switches the pages.