NetworkStream BeginRead & callback invocation

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Back
Top