Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 13 total
Thread Load Data. Real Async?
Thu, Oct 18 2018 4:38 AMPermanent Link

Eivind

All

Just a quick question regarding multiple Load Data requests. In one form I need to load data into 6 Data sets. I fire the load requests all at once the Form show proc. Further down the lines I show the overlay letting the user know that data is being loaded and as one by one dataset returns with data I set a "loaded" flag on each dataset. A timer then runs and wait for all 6 datasets to load and then hide the overlay. When I look at how the browser handles these load requests it looks like they are handled in a sequence? When for example looking at Chromes "waterfall" list it shows that first one request starts, then as soon as the first one completes, the second one starts. Is this how the browsers handles multiple requests, or is this how EWB handles multiple requests?

So, in some cases the user has not been active for some time, and the server triggers a new authentication request. In my Form Show routine I am waiting for all load requests to complete with either success, error or timeout. However, if the first load request fails, that request ends up in the Pending request queue as it should. However, none of the subsequent requests are even sent to the server. The 5 other requests all end up in the Pending request queue as well. I'm perfectly ok with this, I just have to understand if this is browser dependent or how EWB / Javascript is designed?

Originally I designed my system to await for all 6 requests to come back with either a success, error or timeout status. Now, only the first request comes back. Lets say the first request comes back with a 403 timeout I will obviously have the user re-authenticate and retry the pending requests. That works perfectly fine now after Tim pointed med in the right direction in another thread regarding usage of cookies.

So if one request fails, will *ALWAYS* the reminder of the requests fail as well and not even being sent to the server? Again, just trying to design my re-authenticate / retry request feature correctly. If that is the case, can I then based on that always start the retry or re-authenticate process once one request fail? (As the rest will end up in the pending request queue anyway)

Thanks

Eivind
Thu, Oct 18 2018 9:09 AMPermanent Link

Walter Matte

Tactical Business Corporation

JavaScript is single threaded.

https://www.elevatesoft.com/forums?action=post&category=ewb&id=ewb_general&page=1&msg=10222


If you do 6 dataset loads in the Form Create they are queued - executed one at a time.   

In the case you describe - I would load one - and then on its the Onloaded - do the next load - etc myself - then you know when the last one is loaded - they are all loaded.  Easier to handle error conditions ....

Walter
Thu, Oct 18 2018 9:10 AMPermanent Link

Walter Matte

Tactical Business Corporation

Thu, Oct 18 2018 11:08 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/18/2018 9:09 AM, Walter Matte wrote:
> JavaScript is single threaded.
>

Yes but web requests are async so you can definitely run multiple
requests simultaneously.

in EWB it's the TServerRequestQueue that runs requests one by one.

If you want multiple concurrent then you have to use multiple
TServerRequestQueues

Raul



Thu, Oct 18 2018 11:19 AMPermanent Link

Raul

Team Elevate Team Elevate

On 10/18/2018 4:38 AM, Eivind wrote:

> Just a quick question regarding multiple Load Data requests. In one form I need to load data into 6 Data sets. I fire the load requests all at once the Form show proc. Further down the lines I show the overlay letting the user know that data is being loaded and as one by one dataset returns with data I set a "loaded" flag on each dataset. A timer then runs and wait for all 6 datasets to load and then hide the overlay. When I look at how the browser handles these load requests it looks like they are handled in a sequence? When for example looking at Chromes "waterfall" list it shows that first one request starts, then as soon as the first one completes, the second one starts. Is this how the browsers handles multiple requests, or is this how EWB handles multiple requests?

EWB - TServerRequestQueue does the serialziation

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2&comp=TServerRequestQueue


> So, in some cases the user has not been active for some time, and the server triggers a new authentication request. In my Form Show routine I am waiting for all load requests to complete with either success, error or timeout. However, if the first load request fails, that request ends up in the Pending request queue as it should. However, none of the subsequent requests are even sent to the server. The 5 other requests all end up in the Pending request queue as well. I'm perfectly ok with this, I just have to understand if this is browser dependent or how EWB / Javascript is designed?

EWB dependent and you can control what to do.

Manual has a pretty good overview of how requests work

https://www.elevatesoft.com/manual?action=topics&id=ewb2&section=using_server_requests


> So if one request fails, will *ALWAYS* the reminder of the requests fail as well and not even being sent to the server? Again, just trying to design my re-authenticate / retry request feature correctly. If that is the case, can I then based on that always start the retry or re-authenticate process once one request fail? (As the rest will end up in the pending request queue anyway)

You can decide what to do in case of failure - try again or cancel - and
that determines what happens with next requests.

Failure might be transient (really depends what it was - network,
server, etc) so retry might work or next request again might work fine

Raul
Thu, Oct 18 2018 12:04 PMPermanent Link

Walter Matte

Tactical Business Corporation

Raul

How would you do multiple Database.LoadRows() Async?

Walter
Thu, Oct 18 2018 12:14 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/18/2018 12:04 PM, Walter Matte wrote:
> Raul
>
> How would you do multiple Database.LoadRows() Async?

You cannot - in this case you are using built-in TDefaultDatabase (which
is just a TDatabase with some default names) which has a built-in
TServerRequestQueue which enforces serialization.

To do multiple you need to have multiple TDatabase instances and then
you can run in parallel.

This is all EWB design to provide consistent and predictable operation
and not javascript limitation.

Raul
Thu, Oct 18 2018 3:19 PMPermanent Link

Walter Matte

Tactical Business Corporation

Understood - Elvin was asking about Datasets.

Walter
Thu, Oct 18 2018 3:21 PMPermanent Link

Walter Matte

Tactical Business Corporation

Sorry - Eivind

Walter Matte wrote:

Understood - Eivind was asking about Datasets.

Walter
Thu, Oct 18 2018 5:05 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/18/2018 3:19 PM, Walter Matte wrote:
> Understood - Elvin was asking about Datasets.

Yes - so basically as long as you create 6 databases you can load 6
datasets in parallel in EWB.

Database in EWB is a virtual construct so they can all point to same
back end URLs and etc.

However, all of this is likely not worth the effort since you're trading
(potentially) bit of speed over complexity.

Raul
Page 1 of 2Next Page »
Jump to Page:  1 2
Image