Bug? Resumable sub already completed

Alessandro71

Well-Known Member
Licensed User
Longtime User
I have a background task (actually a Bluetooth device scan) that I have to wait completion.
To not forcing the user to wait for it, I coded it as a resumable sub, run it and, while it runs, perform some user interaction.
B4X:
Dim BLEScan As Object    'for waiting on
BLEScan = Globals.bluetoothDevs.ScanBLE        'start background scanning
' ...
'user interaction code that have variable completion time
' ...
ToastMessage.ShowProgress("Scanning Bluetooth")
Wait For (BLEScan) Complete (success As Boolean)
ToastMessage.HideProgress
If the user completes the iteraction before the scan is completed, the Wait For works as intended, waiting for the sub to complete before proceeding.
If the user is slow and the resumable sub completes beforehand, the Wait For causes a crash with

Resumable sub already completed

Shouldn't the Wait For just go through with no waiting and no error either?
 
Top