|
| [WD22] How to Get Data Source from Thread |
| Iniciado por guest, 01,mar. 2018 16:49 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 01,marzo 2018 - 16:49 |
1. How can I tell if a Data Source var has been initialized? 2. How can I access a threaded Data Source var in the main thread? I tried using a global data source, but that did not work. I also tried using the various constants for the second param in ThreadExecute(). Thread params are passed by value, not address, so I understand why dsRes isn't ever initialized in LoadTable().
PROCEDURE LoadTable() IF ThreadState("ItemList") <> threadRunning THEN ThreadExecute("ItemList", threadNormal, ItemList, dsRes) ThreadWait("ItemList", 1000) END FOR EACH dsRes // Error here, dsRes is not initialized // Fill Table (TableAddLine()) END PROCEDURE ItemList(dsRes is Data Source) sQry is string = "SELECT * FROM Universe" IF NOT HExecuteSQLQuery(dsRes,hQueryDefault,sQry) THEN Error("Oops") END |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,marzo 2018 - 08:01 |
Hi,
You can build a class that holds the data and the function you call in a thread, that the data source can me a member variable. This is the basics of the Class mapping files of Andy for example.
You need to trigger or call a "display" routine after you have loaded your data. But because this is touching the GUI it needs to run in the main thread. You can use the thread settings of the function or use ExecuteMainThread todo this.
You can get your data in the thread and as soon as the data is received you call an "update display" routine on the mainthread that updates the data on the screen.
You could also pass the datasource to the update routine if you don't use any classes.
I use loading data in a thread in the background and updating the GUI a lot, so it works.
Danny |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 14 mensajes |
|
| Publicado el 24,julio 2018 - 12:00 |
IF HFileExist(dsRes)
Best regards! |
| |
| |
| | | |
|
| | | | |
| | |
|