Is long loop ANR-safe?

Hello All!
I iterate long file inserting into DB using single line inserts (couple of blocks like loop while lines available (parse line, insert line into db). It can take a while.
I

  1. Will AppInventor runtime protect me against ANR (application not responding error) ?
  2. If not, what should I do (call) so to allow app to process user events ?
    Please note that with single-row inserts I do want to avoid async inserts (that would create need for global variables that I do not like - I'd rather call something each 100 inserts).
    Regards

What kind of DB are you inserting into?

Look for a DB with Bulk Insert capabilities, like SQLite.

Thanks for prompt reply and suggestion.
My question however is about learning AppInventor and the db operation is an example- the question is about handling long loops in GUI thread.
There are 2 cases:

  1. Long blocking operation (e.g. BluetoothClient.Connect) - these I handle using co.sgext_.asyncprocedure.aix
  2. Long loops of short operations - I do not know if AppInventor implementation is makes it "blocking" or not...
    Regards

For a long computation like a Sieve of Eratosthenes prime number finder demo, I have found it necessary to break up the computation into a list feeding a Clock Timer.

Most long running activities have completion events.

1 Like