B4J Question Wait For.... different ways of acting

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
I have this code (I use Java11):

B4X:
Private Sub btesciman_Click
    CallSub2(Me, "AcquireM", False)
End Sub

Sub ReadManual(lb as B4xView)
.....
Wait For AcquireM (b As Boolean)
If b = False Then
.....

In debug mode without breakpoint the program exits with errors
This is the error
''
Error occurred on line: 2269 (Main)
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:487)
at b4j.example.main._btesciman_click(main.java:3671)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:134)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
... 25 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:40)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:110)
... 26 more
''

if I put a breakpoint in
B4X:
CallSub2(Me, "AcquireM", False)
and I continue in steps with F8 alla work fine.
It works without exiting the program in release mode.

Thanks
 

micro

Well-Known Member
Licensed User
Longtime User
You have to call ReadManual, before
Infact
B4X:
Sub ReadManual(lb as B4xView)
.....
Wait For AcquireM (b As Boolean) '<--the code is here waiting'
If b = False Then
.....
I also tried callsubdelayed2 but is the same
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
ReadManual <--- somewhere in the same module
only after that:
CallSubDelayed2(Me, "AcquireM", False)
Si LucaMs
Sono già in quella Sub richiamata da un'altra parte e resto in attesa del'AcquireM sollevata da un'altro modulo.
Quel CallSub2(Me, "AcquireM", False) in Private Sub btesciman_Click è per forzare l'attesa e uscire dalla Sub.
Comunque ora con CallSubDelayed2 sta andando ?‍♂️....strano
Prima faceva esattamente la stessa cosa
'
Yes LucaMs
I'm already in that Sub called somewhere else and I'm waiting for the AcquireM raised by another module.
That CallSub2(Me, "AcquireM", False) in Private Sub btesciman_Click is to force waiting and exit the Sub.
However now with CallSubDelayed2 it is going ?‍♂️.... strange
Before, the problem was the same even with CallSubDelayed2
 
Upvote 0

Similar Threads

Top