- When does DataAvailable really fires?
After data has arrived and we are done processing an internal poll.
- If new data arrives while DataAvailable is currently executing, can it
overrun another DataAvailable event or will - when the current
DataAvailable
event finishes - another DataAvailble fire?
Another will fire.
Here's the logic under the hood:
1) The event loop calls Poll internally (or you call Poll manually).
2) Some data has arrived, so we read it into an internal buffer
3) We do some more processing (sends, errors, etc)
4) We begin firing events, since data has arrived, we clear our read
flag and call DataAvailable.
***5) More data arrives, but we don't notice it because you're
processing the DataAvailable event -- not servicing the event loop.
6)You leave the DataAvailable event, control returns to the framework.
7) Goto 1.
*** If you call DoEvents or Poll from within the event, then things
change a bit. If more data has arrived, and you call Poll, then you can
re-enter the DataAvailable event.
So what is there to learn about this?
1) Don't mix asynchronous and synchronous socket behavior. If you're
going to be calling Poll and waiting in loops, then don't use events.
If you're using events, don't call Poll. Mixing these two different
paradigms can lead to some hard to track down bugs if you're not careful.
2) You don't have to worry about data arriving during an event, it still
gets processed once you return control back to RB and a new event will fire.
HTH!
~Aaron
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|