Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Updating during processing
Tue, Jan 10 2017 12:17 PMPermanent Link

Matthew Jones

Is there a nice way to update some activity indicator while in a tight loop? Specifically, I'm loading a big load of JSON data into a list, and it takes something like 5 seconds or more. I'd like to show progress in a real manner. But I think that if I set a label to show progress, it won't update until the processing finishes. Is this right?

I can set up some sort of async thing with a current state, but that would significantly complicate the JSON reader, given it is not under my control currently.

Any thoughts? (A simple spinner doesn't really do the job any more than a "loading" does...)

--

Matthew Jones
Tue, Jan 10 2017 1:36 PMPermanent Link

Matthew Jones

Matthew Jones wrote:

> I'm loading a big load of JSON data into a list, and it takes something like 5 seconds or more

Always worth doing some measuring. The JSON loads in no time. The grid (unbound) was taking over 10 seconds. Not hard to make that into a procedure called with Async to fill 10 at a time and update a TLabel to show progress. And of course when I added BeginUpdate/EndUpdate around that, it takes only 4 seconds. All much better now.


--

Matthew Jones
Wed, Jan 11 2017 2:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Always worth doing some measuring. The JSON loads in no time. The grid (unbound) was taking over 10 seconds. Not hard to make that into a procedure called with Async to fill 10 at a time and update a TLabel to show progress. And of course when I added BeginUpdate/EndUpdate around that, it takes only 4 seconds. All much better now. >>

This is one of the major issues with the single-threaded nature of JS, and one that web worker support doesn't entirely solve because of the need to be interacting with the DOM/UI, which is not supported with web workers.  It's tough nut to crack without doing exactly what you've settled upon: arbitrarily chopping up code in a way that allows the UI thread to process messages in-between blocks of JS code execution.

Tim Young
Elevate Software
www.elevatesoft.com
Image