Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 10 Monaten
Letzter Beitrag:
vor 1 Jahr, 10 Monaten
Beteiligte Autoren:
ccc2, Fabrice Harari, Ruben Sanchez Peña

[wm21 - android] how to end a thread in android ?

Startbeitrag von ccc2 am 06.10.2016 10:24


with threadstop() / threadEnd() not supported on android , how do I end a thread in android ?



Hi. Yes. Android doesn't support threadstop. You must send signals to thread or global vars to stop the loop execution and it stop self. See http://doc.windev.com/en-US/?9000108


von Ruben Sanchez Peña - am 06.10.2016 15:18
I tried that method before but there's problem . slow. I can't terminate it right away, while in process of httprequest from webservice.

my windows have 2 looper , first looper is manufacture , the second looper is product.
when user press on looper1 ,
1. clear looper2
2. request product list from webservice base on manufacture selected
3. fill looper2 with product list

using signal , i can't kill the process right away. because of that when user select another manufacture will get error thread exist .

the following solution I don't want:
1. create new thread whenever user select manufacture ,using random name for thread to avoid error thread exist. it is bad to leave multiple process still running in background

2. gray out looper1 after select and enable it after process finish. the user don't want to wait

is there a better solution ?

von ccc2 - am 06.10.2016 16:12

AFAIK, a threadstop would NOT stop the thread DURING the httprequest, but only when the answer arrived (I don't think it does even in WinDev).

So no, I don't think there is another solution than to use a pool of threads, or to wait for the thread to be ready before going further

Best regards

von Fabrice Harari - am 06.10.2016 18:53
Thank guys for all your suggestion

I decide not to use thread. just gray out the looper1 and after looper2 finish , enable looper1

Proble for Rubén suggestion

1. ThreadSendSignal / ThreadWaitSignal are more suitable for sync code execution . ThreadWaitSignal is same as wait (it will wait for signal to continue )

2. create new thread and use global variable to tell the thread when to stop. the risk for this is there is small chance that one record (product) from previous select manufacture add into the current selected manufacture.

for example

-- if threadName "1234" then return
-- looperaddline (looper2) ---> if threadName change at this point , one record will added into looper2
-- if threadName "1234" then return

Problem for Fabrice suggestion
1. use a pool of threads, or to wait for the thread to be ready before going further .
since going to wait then no different with not using thread

von ccc2 - am 07.10.2016 05:58
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.