PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [wm21 - android] question about ExecuteMainThread()
[wm21 - android] question about ExecuteMainThread()
Iniciado por guest, 08,nov. 2016 05:22 - 1 respuesta
Publicado el 08,noviembre 2016 - 05:22
Hi,

can anyone explain in detail the flow of process of ExecuteMainThread() ?

help explain "Triggers the execution of a procedure by the main thread of the application"

I don't understand . when is the execution start ?

for example if I have 5 looper in a windows , each looper create one thread to retrieve data and fill into the looper . in each thread i use ExecuteMainThread(add_row) to add to looper.

This is my assumption what will happen:
since I have 5 thread running with mean there will be 5 request "Triggers the execution" to main thread. this cause main thread to execute one request at a time.
If main thread is busy then the 5 request "Triggers the execution" will have to wait until main thread is free

am I right ?
Publicado el 08,noviembre 2016 - 05:31
my suspicious come because of LooperAddInProgress (Function) example

///////////////////////////// EXAMPLE ////////////////////////////////////////////////////////////////////////////
// [Adding additional elements] process
LooperAddInProgress(LOOP_MyLooper, True)
ThreadExecute(myProcGetAdditionalResult)


// -----
PROCEDURE myProcGetAdditionalResult()

QRY_MoreData.MinID = LOOP_MyLooper[LOOP_MyLooper..Occurrence].ID
HExecuteQuery(QRY_MoreData) // Run a long query
HReadFirst(QRY_MoreData)
WHILE NOT HOut(QRY_MoreData)
// Adds elements to the looper from the main thread to modify the GUI
// AddIntoMainThead will use the WLanguage ExecuteMainThread function
AddIntoMainThead(LOOP_MyLooper, QRY_MoreData.Title, ...
QRY_MoreData.Photo, QRY_MoreData,ArticleID)
HReadNext(QRY_MoreData)
END

LooperAddInProgress(LOOP_MyLooper, False)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

what the different if I put the whole code of myProcGetAdditionalResult in ExecuteMainThread() calling procedure


PROCEDURE myProcGetAdditionalResult()
ExecuteMainThread(Add_Row)


PROCEDURE Add_Row()
QRY_MoreData.MinID = LOOP_MyLooper[LOOP_MyLooper..Occurrence].ID
HExecuteQuery(QRY_MoreData) // Run a long query
HReadFirst(QRY_MoreData)

WHILE NOT HOut(QRY_MoreData)
LopperAddLine(LOOP_MyLooper, QRY_MoreData.Title, QRY_MoreData.Photo, QRY_MoreData,ArticleID)
HReadNext(QRY_MoreData)
END

LooperAddInProgress(LOOP_MyLooper, False)