Recent

Author Topic: LAMW problem with jProgressBar invalidate  (Read 2323 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
LAMW problem with jProgressBar invalidate
« on: January 31, 2022, 03:35:58 pm »
Hi, I have a procedure that downloads more than 60,000 records from a json server and I would like to show the update through the progressbar. I use this code:

for ... do
begin

                         if (Self.ProgressBar1.Progress mod 100)=0 then
                         begin
                            Self.ProgressBar1.Invalidate;
                            //Self.Invalidate;
                         end;

end;

But it does not work. I see the progressbar update only when it has finished the whole loop. How do I resolve?
Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

loaded

  • Hero Member
  • *****
  • Posts: 878
Re: LAMW problem with jProgressBar invalidate
« Reply #1 on: January 31, 2022, 05:49:52 pm »
Hi,
The operation you want is done using AsyncTask.
LAWM has a sample demo on this subject.
You can find it in the ....\lazandroidmodulewizard-master\demos\GUI\AppAsyncTaskDemo1  folder on your system.
The more memory computers have, the less memory people seem to use. 😅

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: LAMW problem with jProgressBar invalidate
« Reply #2 on: February 04, 2022, 02:36:20 pm »
I tried the example you suggested, but I have two problems.

1. If I don't put the sleep in the DoTask the program crashes

2. If in the DoTask I enter

jSqliteDataAccess1.InsertIntoTable(sql);             

crashes.
My need is to populate a sqlite db with more than 65000 records retrieved from a json on web server. I can download the json but I can't save it in sqlite and at the same time update the progress bar.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: LAMW problem with jProgressBar invalidate
« Reply #3 on: February 04, 2022, 04:00:11 pm »
Forget it, I fixed myself with recursive jtimers where I process N records at a time.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018