PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Android Fatal Thread Problem
Android Fatal Thread Problem
Iniciado por guest, 12,dic. 2017 15:09 - 4 respuestas
Publicado el 12,diciembre 2017 - 15:09
This ONLY happens with Android. Same code runs on iOS and Windows. Running on an Android A5.

I start a thread:
ThreadExecute("Validate", threadNormal, ValidateLogin)

In the local ValidateLogin procedure I issue this:
STC_ProgMessage = "Logging in Online ..."
RequestUpdateUI()

I have also tried ExecuteUpdateUI()

However, only in Android I get this fatal error message:

"Only the original thread that created a view hierarchy can touch its views"

Yet RequestUpdateUI() attempts to refresh the window in the original thread. If it works in Windows and iOS why not Android but more importantly how do I fix this. It appears to be a Fatal error.

Thx to anyone who can help.
Publicado el 12,diciembre 2017 - 15:36
Hi John,

from it's prefix, I'm gathering that STC_ProgMessage is a static FIELD in your window.

An that means that you are trying to mess with the UI from inside a secondary thread.

And that, as explained CLEARLY in the threads help, is a BIG NO NO.

Store your value in a variable, NOT a field, and then your local to the window update code that put that value in a field. Or use the tExecuteMainThread function and pass the value as parameter to a local function that will do the display...

If it currently works in iOS, but SURE that at some point you'll end up with unexplained 'random' errors.... Coming straight from there.

Best regards
Publicado el 12,diciembre 2017 - 15:53
Oh thank you Fabrice. I will read the help again. I am sure it said the idea of RequetUpdateUI() was to overcome this exact issue and to be able to update UI in the original thread. I didn't see any mention of variables. Thx.
Publicado el 12,diciembre 2017 - 16:25
Thank you so much once again Fabrice. I still don't think the help made it that clear first time. Re reading it and it seems "implied" what to do.

Anyway I used ExecuteMainThread and it seems to work other than the same failure later in the process so will check that out.

Very much appreciated.

John
Publicado el 12,diciembre 2017 - 16:53
requestUpdateUI does exactly what is says and is NOT the problem

The problem is the line BEFORE it, where you put by code a value in a field of your UI... THAT is forbidden.