# Application "not responding" while LOOP executes

**URL:** <https://clarionhub.com/t/application-not-responding-while-loop-executes/4168>\
**Category:** questions\
**Tags:** c11\
**Created:** [May 22, 2021, 4:40pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168 "2021-05-22T16:40:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [May 22, 2021, 4:40pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168/1 "2021-05-22T16:40:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MarkGoldberg](https://clarionhub.com/user_avatar/clarionhub.com/markgoldberg/32/1511_2.png) [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Post date:** [May 22, 2021, 5:00pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168/2 "2021-05-22T17:00:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [May 22, 2021, 5:01pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168/3 "2021-05-22T17:01:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [May 22, 2021, 5:15pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168/4 "2021-05-22T17:15:20Z")

</div>

Read the “YIELD” topic in the docs.

---

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [May 22, 2021, 8:10pm UTC](https://clarionhub.com/t/application-not-responding-while-loop-executes/4168/5 "2021-05-22T20:10:46Z")

</div>

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.
