'usage
ReadData(5000)
Wait For DataReceived (Success As Boolean, Data() As Byte)
Sub ReadData (Timeout As Int)
Dim b() As Boolean = Array As Boolean(False)
TimeOutImpl(Timeout, b)
Wait For Astream_NewData(Data() As Byte)
If b(0) = false Then CallSubDelayed3(Me, "DataReceived", True, Data)
b(1) = true
End Sub
Sub TimeOutImpl(Duration As Int, b() As Boolean)
Sleep(Duration)
If b(0) = false Then CallSubDelayed3(Me, "DataReceived", False, Null)
b(1) = true
End Sub