Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Optimising display updates
Tue, Apr 26 2016 11:44 AMPermanent Link

Matthew Jones

I have a TScrollPanel which I use to parent a number of TForms, each
one operating as an editor for an item of data. When creating a fair
number of them (150), it can take a while to build them all.

Now, I will work on speeding these up, including displaying only what
is needed initially, and then using OnIdle to build the rest, but is
there anything I can do to make things faster?

I currently have a BeginUpdate and EndUpdate on the TScrollPanel. This
halves the time to load (from 59 to 29 seconds). But will it be
applying to the forms themselves? Anything else anyone can suggest for
optimising form creation lots at a time?

--

Matthew Jones
Tue, Apr 26 2016 7:23 PMPermanent Link

Rick

On 27/04/16 01:44, Matthew Jones wrote:
> I have a TScrollPanel which I use to parent a number of TForms, each
> one operating as an editor for an item of data. When creating a fair
> number of them (150), it can take a while to build them all.
>
> Now, I will work on speeding these up, including displaying only what
> is needed initially, and then using OnIdle to build the rest, but is
> there anything I can do to make things faster?
>
> I currently have a BeginUpdate and EndUpdate on the TScrollPanel. This
> halves the time to load (from 59 to 29 seconds). But will it be
> applying to the forms themselves? Anything else anyone can suggest for
> optimising form creation lots at a time?
>

As well as Begin/EndUpdate I use the "asynch" feature to dynamically
create multiple forms/panels in real time which keeps the UI responsive.
Basically just schedules procedure calls into the message loop.

One way is to call the form build procedure via asynch. The build
procedure then calls itself also using asynch. Keeps doing this until
the required number of forms have been built.

--
Rick
Wed, Apr 27 2016 4:56 AMPermanent Link

Matthew Jones

Rick wrote:

> As well as Begin/EndUpdate I use the "asynch" feature to dynamically
> create multiple forms/panels in real time which keeps the UI
> responsive. Basically just schedules procedure calls into the message
> loop.
>
> One way is to call the form build procedure via asynch. The build
> procedure then calls itself also using asynch. Keeps doing this until
> the required number of forms have been built.

Hmm, most interesting. A quick test shows that it doesn't help in the
core time, but it gives a most interesting effect in a simple
replacement. Here is my loop:

       for nItemLoop := 0 to g_xActiveJob.ItemList.Count - 1 do
       begin
           xItem := g_xActiveJob.ItemList.WorkItem[nItemLoop];
   
           CreateFormForWorkItem(xItem);
       end;


Changing it to:

       for nItemLoop := 0 to g_xActiveJob.ItemList.Count - 1 do
       begin
           xItem := g_xActiveJob.ItemList.WorkItem[nItemLoop];
   
           async CreateFormForWorkItem(xItem);
       end;


Gets me 150 copies of the first item. Okay, the capture of the xItem is
probably not working, so let's ignore the variable:

       for nItemLoop := 0 to g_xActiveJob.ItemList.Count - 1 do
       begin
           async CreateFormForWorkItem(
                      g_xActiveJob.ItemList.WorkItem[nItemLoop]Wink
       end;

That gets me 150 errors, as the nItemLoop is now out of bounds. I shall
have to learn more about these closure things - I guess I need to
encapsulate the creation better. And the help indicates "looping" in
the async, which is similar to my Idle idea basically. More
experimenting to do!


--

Matthew Jones
Wed, Apr 27 2016 5:01 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

>  I guess I need to
> encapsulate the creation better


       for nItemLoop := 0 to g_xActiveJob.ItemList.Count - 1 do
       begin
           AsyncCreateFormForWorkItem(
                      g_xActiveJob.ItemList.WorkItem[nItemLoop]Wink
       end;

procedure TfrmOutline.AsyncCreateFormForWorkItem(xItem : TJobWorkItem);
begin                      
   async CreateFormForWorkItem(xItem);
end;

This works as it should, though still with massive pauses due to the
fact that it queues all 150 in one go. It looks like a good option once
I organise it better though, so thank you for the pointer.

--

Matthew Jones
Wed, Apr 27 2016 12:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Now, I will work on speeding these up, including displaying only what is needed initially, and then using OnIdle to build the rest, but is there anything I can do to make things faster? >>

Unfortunately, nothing other than to "not do that", with "that" being creating 150 form instances.

<< I currently have a BeginUpdate and EndUpdate on the TScrollPanel. This halves the time to load (from 59 to 29 seconds). But will it be applying to the forms themselves? >>

Yes, it will apply to the forms themselves, provided that they are already parented to the container TScrollPanel.

Tim Young
Elevate Software
www.elevatesoft.com
Image