|
| [WX] DB Access and Threads - Howto |
| Iniciado por guest, 28,ene. 2015 12:55 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 28,enero 2015 - 12: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 ? |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 16:12 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 19:08 |
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. |
| |
| |
| | | |
|
| | | | |
| | |
|