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. Often, it’s more appropriate to read or write data asynchronously, to prevent hangs of user interface (UI) threads and to increase scalability of services. The essential idea of asynchronous I/O is to start the request and get notified when the action has been completed.
This section examines how the Stream class supports this modus operandi. Even though C# 5.0 introduces a new improved way to deal with asynchronous operations (discussed in great lengths in Chapter 31, “Asynchronous Programming”), we’ll start off by explaining the old Asynchronous Programming ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access