Update UI while service module is running

Rusty

Well-Known Member
Licensed User
Longtime User
I have a large number of SQL inserts to make and in an effort to not have my application "stall", I've put the code to insert all the rows into a service.
Is there a way to show progress on the main activity screen from within the service?
(or is there a better way to accomplish this other than a service?)
Thanks in advance,
Rusty
 

mc73

Well-Known Member
Licensed User
Longtime User
Service code runs in the main thread. It is not different than Activity code.

You should use the new asynchronous methods added to the SQL library. See the SQL tutorial (it was updated).
Seeing the first post I was thinking whether an addition of a progress sub would be useful too, for very big transactions. What is your opinion?
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
How would you handle a progress sub?
I currently have a service that grabs the whole processor. I have a progress bar showing to the user and once the SQL inserts begin, the progress bar halts until all rows are added.
Thanks
Rusty

I moved the whole process into my MAIN and am using the ExecNonQueryBatch. Every X number of rows, I update the progress and execute a DOEVENTS so the UI updates. The batch completed routine cleans up the UI. THe batch completed is executed each time I execute the ExecNonQueryBatch command, but the actual execution of this completed routing only happens upon completion of ALL data import. In other words, if I have 10000 rows to add, and execute one ExecNonQueryBatch for each 1000 rows, I will get 10 executions of the completion routine, but all of them occur after all 10000 rows have been added, instead of 10 times (once per 1000 rows).

Now after having imported all the rows and the UI works ok, the database is locked...Any ideas on why and how to unlock it?
I'm closing and reopening it after import, this does not work.

Is what I've described a "best practices" method? (it doesn't seem so to me :))
Thanks,
 
Last edited:
Upvote 0
Top