Hello
When I use Sleep together with async messagebox (in a class module) the code is crashing. Removing Sleep(0) from the loop works and the messagebox is shown, but the progressdialog is not shown. Is there any way to use both together?
Crash Log:
When I use Sleep together with async messagebox (in a class module) the code is crashing. Removing Sleep(0) from the loop works and the messagebox is shown, but the progressdialog is not shown. Is there any way to use both together?
B4X:
Public Sub Import(ImportFile As String) As ResumableSub
ProgressDialogShow2("Importing...", False)
For j = 0 To ImportTable.RowCount - 1
'Prepare source data code
Sleep(0)
Next
ProgressDialogHide
Msgbox2Async("Do you want to import %1 rows?", "Import", "Yes", "", "No", Null, True) '< Crash when using Sleep(0) in the loop
Wait For Msgbox_Result (MsgResult As Int)
If MsgResult = DialogResponse.POSITIVE Then
'...
End If
End Sub
Crash Log:
B4X:
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to read from field 'java.lang.ref.WeakReference anywheresoftware.b4a.BA$SharedProcessBA.activityBA' on a null object reference
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1706)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.ref.WeakReference anywheresoftware.b4a.BA$SharedProcessBA.activityBA' on a null object reference
at anywheresoftware.b4a.keywords.Common.Msgbox2Async(Common.java:486)
at com.divinglog.divelog.import$ResumableSub_Import.resume(import.java:361)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
... 7 more
Last edited: