B4J Question DoEvents alternative


Active Member
Licensed User
Longtime User
I saw a recommendation not to use DoEvents:

DoEvents should be avoided in all platforms. Use CallSubDelayed if you want to run something after the current sub finishes.

Source: https://www.b4x.com/android/forum/threads/doevents-alternative.68918/#post-437288

But the window freezes if you don't use something to wait a while. And Windows O.S. notifies you that the window is not responding.

I managed to read thousands of lines in a text file without freezes the window like this:
- I use a CallSubDelayed
- Inside the long loop I use a Sleep(0) command

I don't know if there's a better way to do this, but it worked here. If you don't use the Sleep(0) command, the window continues to freeze.

I'm converting a text file of tens of thousands of lines into an Excel spreadsheet.

Is there a more efficient way than using Sleep(0)?

Thank you.