Stream.BeginRead pointless?

  • Thread starter Thread starter Damien
  • Start date Start date
D

Damien

Are the Begin/End Read/Write operations on Stream pointless?

The reason I ask is that the default implementation in Stream in fact
does a synchronous read within the BeginRead operation, and the
documentation indicates that this behaviour "may" be overridden by
specific subclasses of Stream.

So, if I'm writing a generic class that accepts two stream objects,
and wants to ensure that it's getting the best throughput from both
streams, I have to assume that one or both of those streams may in
fact be hiding a synchronous Read - which means further that to get
the most from both streams, I need to spawn a thread for each one -
and once I've done that, I may as well just call Read.

There doesn't seem to be any way to determine whether or not a
particular stream does *in fact* implement these operations
asynchronously. Is my reasoning correct?

Damien
 
Hello,

the default BeginRead creates a new thread by itself, thereby simulating an
asynchronous read. But the FileStream uses more efficient async
techniques....

Kind regards,
Henning Krause
 
Back
Top