I see you have corrected my statements, thats good.
Erel, your NewData example is smart, I think I can use it as long as I am making an MODBUS master.
The RTU MODBUS spesifications says that the frames are separated by at least 3,5character long silent periode. For baud rates above 19200baud it is a fixed value, 1.75 ms. This is quite short compared to the 50ms you use in your routin. If it was a MODBUS slave I was making, I think I could come in to problems if the master sends a new message before the 50ms has elapsed.
No. There is no relation to the main thread.
Is this true? I supose the NewData event is raised in the main thread in a B4J console application. If the main thread is busy while a lot of bytes are received in the AsyncStreams dedicated thread, more bytes are in the buffer when the newData event finaly is raised. Is this right?
Also: When the main thread meets the Sleep(50) in the NewData event, the thread is not sleeping, it just leaves the NewData event, ready to do other tasks, for example handle more NewData events from AsyncStreams. When 50 ms has elapsed, the main thread continues in the first NewData event call. But it can happen that the returning to the routine happens later if the main thread is busy in a long running task. Is this right?