NetworkStream BeginRead & callback invocation

G

Guest

BeginRead/EndRead doc implies the callback will execute and block on EndRead until data is available

"Your callback method should implement the EndRead method. When your application calls BeginRead, the system will use a separate thread to execute the specified callback method, and will block on EndRead until the provided NetworkStream reads data or throws an exception.

Testing this shows the callback is executed only when data is available; ie: if no data is received on the socket, the callback is not called. When EndRead is called within the callback, it returns immediately with the number of bytes read. The implication is also that EndRead will never block if the callback is only executed when data is available..

Same behavior was observed with .NET Compact Framework and regular .NET Framework (desktop)

Is this a known discrepancy in the doc and the real behavior is what we observed in our test

-
Thank
Patrick Gil
Motorola
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top