B4J Question Is this the proper way to wait non-blocking?

MathiasM

Active Member
Licensed User
Hello

I want to wait until a file is finished writing before reading it.
I don't have a lot of experience with threading etc.
I do it this way:

B4X:
Do Until FileWatcher.IsReadable(FullPath)
    Sleep(100)
Loop
            
'Start reading the file here

As I understand it, this code will run to the Sleep command, the sleep command will cause a return and won't interupt the event loop, after 100 ms, the FileWatcher.IsReadable(FullPath) will be evaluated again, start to read of sleep (non-blocking) again for 100 ms.

Is my assumption correct?

Thanks for any insights.
 
Top