|
| Iniciado por guest, 08,ene. 2015 02:42 - 1 respuesta |
| |
| | | |
|
| |
| Publicado el 08,enero 2015 - 02:42 |
Hi I have a class which uses a query which typically takes about 20 seconds to return the dataset. To show the user that something is happening I thought I would run this in a thread. This all appears to work correctly but it 'loses' the data! The data source for the query is declared global to the class & if I just run the LoadData procedure outside of the thread it works fine.
My code for the thread is as follows: ThreadExecute("thLoadData",threadGlobalContext,LoadData) //load recs in separate thread so we know something is happening IF NOT ThreadWait("thLoadData",6000) THEN IF ThreadState("thLoadData") =threadRunning THEN //if timeout exceeded the thread is still running ThreadStop("thLoadData") //so stop the thread {ls_Wait,indControl}..Visible = False //hide the processing icon Error("Unable to load data") //and report the error END END The code for Load Data is simply the SQL query code followed by HExecuteSQLQuery(datasource,hquerydefault,qrycode) HNBrec(Datasource) //force it to stay within proc until all records loaded Checking this value here I get 47953 records returned. If I put the same thing at the end of the procedure containing the ThreadExecute code I get an error that the data source doesn't exist.
Any ideas what I'm missing?
Thanks
David |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,enero 2015 - 09:56 |
Hi David
the thread is simply (and always) running with an INDEPENDANT HF context... And this context will disappear when the thread stops...
So when you ask about the query in your procedure (the one starting the thread), it is unknown, as it exists ONLY inside the thread
Best regards |
| |
| |
| | | |
|
| | | | |
| | |
|