Application "not responding" while LOOP executes

I am using a LOOP to process lines in a CSV file and add in the records it parses.

The code works correctly and all the records are processed. However I noticed that if the app loses focus (say for example I switch over to DebugView++ to watch the debug messages), then the Clarion app stops updating its display window and Windows Task Manager reports the app as “not responding”. But it is still running and executing the loop.

I’m used to similar behavior in MS Access 97 and it is easily solved by the introduction of a DoEvents call somewhere in the loop. I have tried the SLEEP(1) command, since I can’t find an equivalent of the DoEvents method. SLEEP just adds (one) millisecond to each iteration of the loop, but doesn’t help the app to update the display. So I abandoned that idea. There are 77,000 records in one file, and 147,000 rows in another file.

Before the LOOP commences I open a WINDOW and use DISPLAY(?Count) to update a counter in the window. Once the app loses focus, the window is greyed out and doesn’t update until the loop finishes. How do I enable my Clarion app to update the window while it processes the loop?

The equivalent of doEvents is to let the ACCEPT loop run.

I’d suggest a construct where you process X records in your loop, exit the loop, post event:user and return to the accept loop

2 Likes

To stay responsive you need to process in an ACCEPT Event:Timer. Can you use a Process Template that generates that code for you? Be sure to process more than one record per timer, like 20 to 100, or it goes very slow.

Read the “YIELD” topic in the docs.

1 Like

Thanks everyone. I really appreciate the generosity of this community.

The YIELD() function fixed it for me. I also discovered that DISPLAY() would keep the display updated even when focus was lost. I’m not sure why it would work but DISPLAY(?Count) wasn’t working.
So now I am doing both every 1000 records, and everything is running smoothly.