O'Reilly logo

C# 4.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Asynchronous Read and Write Operations

All the I/O operations explained in the previous sections have been of the synchronous kind, meaning the caller is blocked until the data becomes available. Sometimes it’s more appropriate to read or write data asynchronously and get notified when the action has been completed. The Stream class has intrinsic support for this modus operandi.

The essence of this feature is found in Begin/End method pairs, such as BeginRead and EndRead. Where Read is a blocking operation waiting for data to be read and bubbled up to the application, the BeginRead method immediately returns. However, it doesn’t have the requested data available right away. Instead, it will call you back after it has completed. To do so, a callback ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required