Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 3 Jahren
Letzter Beitrag:
vor 3 Jahren
Beteiligte Autoren:
Michael Drechsel, Alexandre Leclerc

[WX] DB Access and Threads - Howto

Startbeitrag von Michael Drechsel am 28.01.2015 11:55

Hi,

I carefully read the post about threads here and saw the nice WXLIVE THREADS youtube video.
But it is not so clear for me how to do it right.

My problem is always the same:

The user defines some filters in my application and click "refresh" button. My application does "hexecutesql" or "httprequest" and (depends of the filter) the user wait and wait and wait till he get an answer from the server.

In the meantime he could drink coffee or make a phone call but it would be nice if he could do something with my program.

Ok, I put the procedure with the "hexecutesql" and "tabledisplay" in a extra thread, but it doesn´t work.
It never refreshes my tables ...

Perhaps I don´t understand it right ...

How do you solve it ? Could anybody explain how to buld a threading modell to avoid the blocked-response-time and Windows-not-responding-hourglass issues ?

Antworten:

Hi Michael,

When you create your thread procedure, select independent HFSQL context. Then in that thread, make your SQL query. Qhen you have your data, you are ready to display it in the main application.

For this, you cannot do it directly, nor can ask the table to display the data in the query, because the query that has the data is in a different HFSQL context. So you must "send" the data.

One way is to call a procedure in your main application thread with ExecuteMainThread() and this procedure will receive in parameter the data to display in your table.

Disclaimer: I never had, yet, to do such a thing, so there might be a better way to do it. So if someone knows better, please jump in and share!

So you main application calls: Thread_UpdateDataForTableDisplay()
The Thread_UpdateDataForTableDisplay() has an independent HFSQL context and makes the long query. When it is done, it calls ExecuteMainThread(DisplayMyBigData,sDataToDisplay,etc.)
Then DisplayMyBigData() is just filling the table again and says to the user the data is there (like hiding the wait message of infinite progress bar).

All the while, the interface was available to the user.

I hope this helps.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 28.01.2015 15:12
Hi Alexandre,

thx for the reply.

I am wondering that there is no "easy" way to do this, like a parameter in "HExecuteqery", which does the same as "multitaskredraw(-1)", or something in "httprequest"

I will try your suggestion and maybe another user has experience with that.

von Michael Drechsel - am 28.01.2015 18:08
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.