B4J Question I am looking for the right waiting method without blocking?

T201016

Active Member
Licensed User
Longtime User
Hi,
I want to wait for the (Shell) to finish saving to the .mp4 file before I go to further instructions for creating another video file.
I do it this way:

B4J:
Do Until FileWatcher.IsReadable(FullPath)
    Sleep(100)
Loop
'Start to the next code line.

The above way seems to be good, but I noticed that sometimes it can turn on the line (to Until ... Loop)
Only half of them save per 100 files. What could be the cause? Too short set time for Filewatcher?
 

emexes

Expert
Licensed User
Longtime User
Three maybe fixes:

1/ after the loop, double-check that the file is still readable
2/ add a short sleep before and after 1/
3/ don't use the same filename each time (or maybe you're already not - I can't tell from the code you've given)

The technique of using a polling loop with a sleep inside it is one that Erel has used, so you're in good company.

 
Upvote 0
Top