Android Question Bluetooth Serial Problem. Delay breaks Buffer / AsyncStreams ???


Licensed User
Longtime User
Help. When I use AsyncStreams as in the BT tutorial, I get a problem if there's any delays in processing the buffer.

I process here:
Sub AStream_NewData (Buffer() As Byte)
   sMsgBuild = sMsgBuild & BytesToString(Buffer, 0, Buffer.Length, "UTF8")
   If sMsgBuild.EndsWith(CRLF) Then   
     ProcessMessage(sMsgBuild) '<<---Jumps out of sub = problem.
     sMsgBuild = ""
   End If   
End Sub

When it jumps out to ProcessMessage I use a dialog box. While I use the dialog box more messages are arriving in AStream_NewData which end up corrupted. This is in debug or release mode. If I remove the dialog box it works fine.

I can also replicate this by putting a debug breakpoint in AStream_NewData. I end up again with corrupted data. Removing the breakpoint fixes it.

This is bad as it appears that AStream_NewData can't really run asyncronously.? Or am I doing something wrong?


Licensed User
Longtime User
I am getting the order changed, and if I try hard enough some corrupted data.

So no modal dialogs? Can I put the BT and AsyncStreams into a service or will that process and thread also get blocked by a modal dialog?
Upvote 0

Similar Threads