PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD20] ParallelTask and RequestUpdateUI()
[WD20] ParallelTask and RequestUpdateUI()
Iniciado por guest, 13,ene. 2016 13:58 - 7 respuestas
Publicado el 13,enero 2016 - 13:58
Hi,

I have some problems with the understanding of RequestUpdateUI().

I saw the Youtube Video from WXLive about these things from Andy Stapleton and he is using "RequestUpdateUI()" to request the screen update.

I try to do the same thing (without classes) but the Windows procedure code "request for refreshing the display" run only one time at start and then never again.

Whats wrong ?
Publicado el 13,enero 2016 - 16:36
Michael
I have not tried this outside of classes but you could try ExecuteUpdateUI() instead.

Also if you change the code section to a procedure by adding
PROCEDURE lpRequestUpdate(pnCode is int = 0) to the section then you can then send the integer as a param and run code selectively within a switch statement.
This also applies to RequestUpdateUI()

Be aware that on opening the window or using either functions without parameter then CASE 0 (If you have one) will always fire.
Publicado el 13,enero 2016 - 16:55
Hi Derek,

ExecuteUpdateUI() runs not in Parallel Task.

I am wondering what is the difference between running RequestUpdateUI() in normal parelleltask code or in classes ?
Publicado el 13,enero 2016 - 17:57
Michael

No time to test this at the moment, may have a play this evening but my understanding is that 'RequestUpdateUI()' will run once the current process is which the call is made has finished.

My understanding is that something along these lines should work - at least if I am understanding the Help correctly
I call a task from my window and this task contains calls to run Parallel tasks....... t is array of 3 Description of ParallelTask t[1]..Procedure = Procedure1 t[2]..Procedure = Procedure2 t[3]..Procedure = Procedure3 ParallelTaskExecute(t[1]) ParallelTaskExecute(t[2]) ParallelTaskExecute(t[3]) ... ParallelTaskWaitAll(t) RequestUpdateUI() You would of course need to wait for all the PTasks to complete but overall the wait will be shorter.

If this is what you are already doing then at the moment I have no other ideas.
Publicado el 14,enero 2016 - 09:44
Hi Derek,

now it works.

I wrote RequestUpdateUI() in the paralleltask code and this was the failure.
Publicado el 14,enero 2016 - 10:02
Hi,

Could it be that the RequestUpdateUI must execute on the mainthread, because it is UI ?

Maybe you can try to use the ExecuteMainThread(RequestUpdateUI) inside the paralleltask ??

It would be logical that you could start a longer paralleltask and that everything continues without having to wait for it. And when the task is finisched that it would trigger a GUI update !

Let us know if the use of ExecuteMainThread worked or not !

Good luck
Danny
Publicado el 14,enero 2016 - 10:22
no, doesn´t work. The window is frozen, no error message.
Publicado el 14,enero 2016 - 14:11
Hi Michael,

It is because ParallelTaskWaitAll(). It blocks the main thread. A very simple solution is set the procedure as a timer that starts 1/100 after it's call. Another solution is to us a thread that starts the PT calculations. Once the thread is finished you can call the Refresh code. If Danny's ExecuteMainThread() trick does not work, simply create a refresh procedure and set it to be executed in the main thread (same place where you set the timer option). Then at the end of your PT thread call it.

Best regards,
Alexandre Leclerc