Just call Sleep(x) directly.
Or Sleep(1000 * x).
Thank you Erel. In this instance calling Sleep directly causes an error. In using Sleep the sub from which it is called becomes a ResumableSub. This interferes with code execution, and I get an error further on.
If I use Sleep(X * 1000) I get this error
main_pop_downloadcompleted (java line: 10556)
java.lang.ArrayIndexOutOfBoundsException: length=21; index=21
at mail.purge.whapp.main._pop_downloadcompleted(main.java:10556)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
java.lang.ArrayIndexOutOfBoundsException: length=21; index=21
If I use the Wait Sub below all is well, with no error. The only problem being that DoEvents has been depreciated.
Sub Wait(Seconds AsInt)
'Sleep for defined seconds
Dim Ti AsLong
Ti = DateTime.Now + (Seconds * 1000)
DoWhileDateTime.Now < Ti
DoEvents
Loop
EndSub
Using Sleep() directly is not always an option, and I would like to have a Wait Sub that doesn’t use DoEvents. If this is not possible I will have to stick with DoEvents for as long as I can, as this is all that works for me.
Regards