iOS Question B4i Beta 5.5 Debug Issue


Well-Known Member
Licensed User
Longtime User
For some reason I am having some weird issues with the debugger of the beta.

This code worked fine prior to installing the beta, even in debug mode:

Sub ScanForDevices
    Dim servicelist, devices As List
    Dim sheet As ActionSheet
    HD.ProgressDialogShow("Searching for Devices, Please Wait.")
    ScanningMode = True 'Scanning only
    DiscoveryMode = False 'No discovery until connecting.
    ScanCancelled = False
    manager.Scan2(servicelist, True)
    ScanTimer.Enabled = True
    Do Until ScanCancelled = True
        Wait For Device_Detected (ReturnCode As Int) 'Wait for any devices to be discovered.
        If ReturnCode = 0 Then 'We continue to scan and add adapters.
            HD.ProgressDialogShow("Searching for Devices. (" & FoundDevices.Size & " Found)") <-- This never executes or updates.
            For Each Key As String In FoundDevices.Keys
                Dim DeviceInfo As Device
                DeviceInfo = FoundDevices.Get(Key)
                devices.Add(DeviceInfo.Name & " " & GetBars(CalculateSignalLevel(DeviceInfo.RSSI, 5)))
                #IF DEBUG
                    Log(DeviceInfo) <--- This works in debug, sometimes.
                #End If
        Else 'The scan has been completed or cancelled.
            ScanCancelled = True
            ScanningMode = False
        End If
    HD.ProgressDialogHide <--- This never gets reached, or the code below it.
    Log("Scan Complete")

    sheet.Initialize("sheet", "Available Devices", "","", devices)
'    Wait For sheet_Click (Result As String)
'    Log(Result)
End Sub

Sub ScanTimer_Tick
    ScanTimer.Enabled = False
    CallSub2(Me, "Device_Detected", 1) 'Call our event to exit the loop on scan complete. (to prevent a "potential" memory leak from an unresolved Wait For. I feel better this way.)
End Sub

Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
    Dim UniqueID As String
    If AdvertisingData.ContainsKey("kCBAdvDataManufacturerData") = True Then 'Make sure only our programmed devices can be discovered.
        UniqueID = AdvertisingData.Get("kCBAdvDataManufacturerData")
        UniqueID = Regex.Replace("[^0-9A-Fa-f]+", UniqueID, "").ToUpperCase
    End If
    If ScanningMode = True And UniqueID = "XXXXXXXXXX" Then 'We are scanning for valid devices. Add them one at a time into our list of available connections.
        If FoundDevices.ContainsKey(Id) = False Then 'If the discovered device is not already in the list, then we add it and move on.
            Dim DetectedDevice As Device
            DetectedDevice.ID = Id
            DetectedDevice.Name = Name
            DetectedDevice.RSSI = RSSI
            FoundDevices.Put(Id, DetectedDevice)
            CallSub2(Me, "Device_Detected", 0) 'Call our Wait For event to add any new entries into the selection list. 0 means scan continue.
        End If
    Else If UniqueID = "XXXXXXXXXX" And SelectedDevice.ID = Id Then 'We have discovered our device
        DiscoveryMode = True
        manager.StopScan 'Stop our scan since we found the device we are looking for.
        manager.Connect(Id) 'Connect to our device.
    End If
End Sub

But now with 5.5 Beta installed, its hit or miss. Mostly miss. itll pop up the Searching dialog, but then nothing happens after that outside of the log print.

I commented above in the code where the trouble spots are. Its really hit or miss, I am chasing my tail because I think its a code issue. So i change some code, it works. then try it again, it quits working.

If I compile in release mode, the code works every time.

Last edited:


Well-Known Member
Licensed User
Longtime User
I do show the dialog before the wait for. I just "update" the dialog afterwords. Cleaning the project does not help. Only building in release mode that everything works. Also everything was working prior to installing 5.5 so I am not sure what the differences are internally.
Upvote 0


Well-Known Member
Licensed User
Longtime User
I can do that. Its very intermittent. Towards the end of the day yesterday, it was magically working fine. Go figure.
Upvote 0


Well-Known Member
Licensed User
Longtime User
Never heard of that function. Trying to search it up to see its function, but cant find anything.

Actually, that function doesnt exist. turns RED.
Upvote 0