Problem With Screen Refresh And Script Taking Too Long!

Here’s a complete example with a GUI which shows a progress and allows to start/stop it:

EDIT: Moved to