B4J Question many tasks and progressbar

MarcRB

Active Member
Licensed User
Longtime User
Hello,

Sorry for my bad English.

What is the best way to show progress with a progressbar, when many tasks have to be done.
Some tasks has to be done in a specific order because later tasks have to use the results.
For example createDB has to be complete before tablefill is started.

I tried working with sleep(0), Wait for, but in all combinations i tested the progressbar is not responding correct.

1. The progressbar stays at 0% until all tasks are complete then changes to 100% and the screen was frozen between 0 an 100%
2 Or the progressbar moves forward, task by task but when de bar is at 100% some tasks are not yet complete.
Or task 4 is busy while task 5 is done and task 6 has an error because the result of task 4 is not yet complete.

Tasks:
Sub CreateAndSendDBfile
    ProgressbarStepReset
    Wait for DeleteOldDBfile
    Sleep(0)
    ProgressbarStepPlus
    Wait for CreateSQLiteDB
    Sleep(0)
    ProgressbarStepPlus
    FillTable1
    Sleep(0)
    ProgressbarStepPlus
    FillTable2
    Sleep(0)
    ProgressbarStepPlus
    FillTable3
    Sleep(0)
    ProgressbarStepPlus
    FillTable4
    Sleep(0)
    ProgressbarStepPlus
    CompactDB
    ProgressbarStepPlus
    UploadDBFile
    ProgressbarStepPlus
End sub
 
Solution
Instead of
B4X:
Wait for DeleteOldDBfile

You may need to change the sub to ResumableSub and return a value.
B4X:
Wait For (DeleteOldDBfile) Complete (Success As Boolean)

MarcRB

Active Member
Licensed User
Longtime User
Aeric,

Thank you,

This was helpful. I already tried the 'same' but because, it didn't work at first time, I never tried it again.
Because you pointed again in this direction. I looked for some examples. This time I noticed the "As ResumableSub" addition to the original sub instead of the original return value type. Now it works.
 
Upvote 0
Top