[wm21 - android] Looper Control strange behaviour

Startbeitrag von ccc2 am 30.12.2016 03:41

I'm doing a simple test on looper selecting a row event . to my surprise , I found that looper on android act alot different than on windows.

--- test ---
1. create a windows .
2. add 1 looper control (column = 1)
3. add 1 static text into the looper (to show index)
4. add a button . code

LooperDeleteAll(LOOP_Content)
M_cnt is int = 1

LOOP(20)
LooperAddLine(LOOP_Content,M_cnt)
M_cnt++

END



5. create a local procedure . name test

PROCEDURE test(LOCAL arg_id is int)
m_time1 is Time = Now()
Multitask(200)
m_time2 is Time = Now()
ToastDisplay(arg_id + " / " + m_time1..Hour + ":" + m_time1..Minute + ":" + m_time1..Second + " / " + TimeDifference(m_time1, m_time2) )


6. in looper control selecting row event add code
m_id is int = LOOP_Content[LOOP_Content..Value].ATT_Id
test(m_id)

7. compile and deploy to android device

8. test it by slowly press row 1,2,3 and wait

you will see toast display in backward order than what you press and time different also different

- id= 3 -> time different 200
- id= 2 -> time different 296
- id= 1 -> time different 391

i repeat many times, but the toastdisplay will always show in backward order of what i pressed


Question
1. looper in android seems to be multi threads by default while on wd windows is single threads . if that the case toastdisplay should still show in 1,2,3 order , not 3,2,1 order.

2. the time different . i use Multitask(200) which mean the different should be around 200. not 400 . what happen to the first row i press ?

3. is it save use multitask in android?

Antworten:

Next I test by removing multitask(200)

this time toastdisplay() show in same order as I pressed . and prove that looper control default is multi threads

von ccc2 - am 30.12.2016 03:47
Next, I test using ThreadPause(200)

this cause the looper behave like single thread. like in windows.
I can't press next row , I have to wait process finish then i can press next row

-----------------------------------------------------------------------------
next , I use

m_i is int = 0
LOOP(500000)
m_i++
END

to my surprise looper behave like multi thread. I can continue press next row without need wait.

I pressed 1,2,3 then wait

toastdisplay
id : 1 -> time diff 5
id : 2 -> time diff 5
id : 3 -> time diff 7


interesting to know what multitask , threadpause, loop can cause

von ccc2 - am 30.12.2016 04:19
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.