Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 11 Monaten, 1 Woche
Letzter Beitrag:
vor 11 Monaten, 1 Woche
Beteiligte Autoren:
Danny Lauwers, Fabrice Harari, Ericus

[WB19] Page Initialise Best Practice

Startbeitrag von Ericus am 14.06.2017 09:44


I open a page and at the same time populate 4 loopers with data from 4 different queries based on the parameter passed to the page.

This takes a couple of seconds to do.

What is the best practice to open the page and update the loopers in the background but at least the user can see the page and the fields they are going to complete?

I have tried ThreadExecute where I execute the 4 queries and use looperdisplay to refresh the loopers. However the looperdisplay does not work from the ThreadExecute. Something to do with the HFSQL context being duplicated?

If I run the same procedure but not as a thread, then it works, but then the display is delayed by the few seconds to display the loopers.

Thanks in advance for any pointers.

Ericus Steyn


Hi Ericus,

I would use ajax to do what you want:
- either (if it's already available in 19) with an ajaxececute call with the refresh display option in the page load browser code
- or, if that option appeared later than 19, with an execute process of a hidden button, and in the button sever+AJAX code, the reading of data and filling of loopers

You can even user four successive calls using that principal, if you want to stagger the apparition of data.

Best regards

von Fabrice Harari - am 14.06.2017 11:13

I also tried to run an AjaxExecuteAsync call in the onLoad browser function, but for some reason this was not processed in the background :confused:, the delay before the controls where displayed was the same. You can use Chrome F12, or a Chrome Extention called Performance-Analyzer. That displays where the delay is and how your page loads etc...
Very interesting: https://chrome.google.com/webstore/detail/performance-analyser/djgfmlohefpomchfabngccpbaflcahjf

I use the following method to run something "in the background" do this.

1) In the load (onload) event for the browser run a global Browser function from the Template (B_DisplayReload_Async)

2) In that browser function I start a timer with a very very little delay
gnAfterOnLoadTimer = Timer(B_AfterOnLoad_Timer,1)

By doing this the onload function of the browser directly returns and can display the layout.

3) After that little time (10ms) the function B_AfterOnLoad_Timer of my Template is called

4) In the function B_AfterOnLoad_Timer I do

// Start an async task, for updates that are delayed
Res is int
Res = AJAXExecuteAsynchronous(ajaxUpdateControls,Display_Async,B_Display_Async_Ready)

I call the B_Display_Async and B_Display_Async_Ready functions.

In the pages I need this background functionality I just override the Template function Display_Async and fill it with the code that gets the data, updates the tables/loopers etc.

During the "load" time, the user sees the page and all of its controls and is presented with a wait dialog until the data is loaded/processed. When that is done the B_Display_Async_Ready function is called.

In the B_Display_Async_Ready function, I hide the wait dialog.

I don't know if this is the best solution, but it seems to work :rp:.

I would like that PC-Soft would make some async event on the page todo this 'out-of-the-box'.

If you find any improvements on my method, please let me know !

Have a nice day

von Danny Lauwers - am 15.06.2017 13:51
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.