I encountered the following situation. I don't know where is my problem.
I created a test project because I expected one of my other subroutines influence the application and result in the described behaviour
With the test project I found the reason in a sleep(10) instruction
A brief description of the main activity:
Two buttons, button1 and button2, using the same Click Event "Button_click" added with the designer
The Button_Click event fires an event "clicked" which is "sampled" through a wait for instruction in the class objllk
Two "callback" functions of the class objllk. One changes the color of the two buttons, the other one changes the text attribute of button1
A brief description of the class objllk
This class just waits for the forwarded click event of the main activity through the event "clicked"
Each event changes an internal counter form 0 to 2 for the inner loop
Every completed innerloop changes the color of the buttons and shows the value of the counter of the outer loop
Change the color and show the value are two "callback" functions addressed to active instance of the class objllk
When I compile the sample project in DEBUG mode the test project works as I expected.
If I compile the sample project in RELEASE mode with the SLEEP (10) instruction in the subroutine test of the class objllk then the program does not what I expect.
After the SLEEP(10) instruction the event "clicked", fired by the button_click event of the main activity, does not continue the program flow after the wait for instruction of the subroutine test of the class objllk.
If I compile the project in RELEASE mode without the SLEEP(10) instruction in the subroutine test the class objllk then the program runs as I expect
I attached the project with the logs of the small programm as comments in the subroutine test of the class objllk
Just for reference the subroutine test of the class objllk
Where is my problem? Do I understand the idea of RESUMABLE subs and WAIT FOR {event} and SLEEP still wrong?
My skill of JAVA is to low to fully understand and following the details of the generated JAVA Source files to find out my problem.
Any help , go around and explanation is welcome
Mading
I created a test project because I expected one of my other subroutines influence the application and result in the described behaviour
With the test project I found the reason in a sleep(10) instruction
A brief description of the main activity:
Two buttons, button1 and button2, using the same Click Event "Button_click" added with the designer
The Button_Click event fires an event "clicked" which is "sampled" through a wait for instruction in the class objllk
Two "callback" functions of the class objllk. One changes the color of the two buttons, the other one changes the text attribute of button1
A brief description of the class objllk
This class just waits for the forwarded click event of the main activity through the event "clicked"
Each event changes an internal counter form 0 to 2 for the inner loop
Every completed innerloop changes the color of the buttons and shows the value of the counter of the outer loop
Change the color and show the value are two "callback" functions addressed to active instance of the class objllk
When I compile the sample project in DEBUG mode the test project works as I expected.
If I compile the sample project in RELEASE mode with the SLEEP (10) instruction in the subroutine test of the class objllk then the program does not what I expect.
After the SLEEP(10) instruction the event "clicked", fired by the button_click event of the main activity, does not continue the program flow after the wait for instruction of the subroutine test of the class objllk.
If I compile the project in RELEASE mode without the SLEEP(10) instruction in the subroutine test the class objllk then the program runs as I expect
I attached the project with the logs of the small programm as comments in the subroutine test of the class objllk
Just for reference the subroutine test of the class objllk
Code:
Sub test
Dim NumOfClick As Byte
Dim NumofHints As Long
Do While hint(NumofHints) =5
NumofHints=NumofHints+1
NumOfClick=0
Do Until NumOfClick=2
Log ("wait for Click event")
wait for clicked
NumOfClick=NumOfClick+1
If NumOfClick=2 Then show (NumofHints)
Log ("After click event " & NumOfClick & " NumofHints " & (NumofHints Mod 3))
Loop
'********************************
'????????????????????????????????
'In DEBUG Mode the subroutine test runs as I exect
'It seems that the sleep(10) instruction in line 72 is the reason why the subroutine
'does not function in RELEASE mode compare to DEBUG Mode.
'In RELEASE mode for compilation with activated sleep(10) instruction the subroutine test does not what I expect
'The event of the wait for instruction is not fired again after excecuting the sleep instruction
'The log screen
' ** Activity (Main) Pause, UserClosed = False **
' *** Service (Starter) Create ***
' ** Service (Starter) Start **
' ** Activity (Main) Create, isFirst = True **
' ** Activity (Main) Resume **
' wait for Click event
' Button_click
' After click event 1 NumofHints 1
' wait for Click event
' Button_click
' Button value 1
' After click event 2 NumofHints 1
' wait for Click event
' Button_click
' Button_click
' Button_click
' Button_click
' Button_click
'In DEBUG and RELEASE mode the subroutine works
'with deactivated sleep(10) instruction as I exspect
'the log screen
' --------- beginning of system
' *** Service (Starter) Create ***
' ** Service (Starter) Start **
' ** Activity (Main) Create, isFirst = True **
' ** Activity (Main) Resume **
' wait for Click event
' Button_click
' After click event 1 NumofHints 1
' wait for Click event
' Button_click
' Button value 1
' After click event 2 NumofHints 1
' wait for Click event
' Button_click
' After click event 1 NumofHints 2
' wait for Click event
' Button_click
' Button value 2
' After click event 2 NumofHints 2
' wait for Click event
' Button_click
' After click event 1 NumofHints 0
' wait for Click event
' Button_click
' Button value 3
' After click event 2 NumofHints 0
'
'What is my problem? What I am doing wrong?
Sleep(10)
Loop
End Sub
Where is my problem? Do I understand the idea of RESUMABLE subs and WAIT FOR {event} and SLEEP still wrong?
My skill of JAVA is to low to fully understand and following the details of the generated JAVA Source files to find out my problem.
Any help , go around and explanation is welcome
Mading
Attachments
Last edited: