Asynchronous Programming Model

The oldest of the asynchronous programming patterns was introduced right from the start, with .NET Framework 1.0. We’ve already covered this pattern in passing in Chapter 17, “Delegates,” and in Chapter 28, “Working with I/O.” Nonetheless, let’s revisit this pattern briefly and identify its core characteristics.

This pattern consists of two related methods, using a Begin and End prefix convention. For example, asynchronous read operations on a Stream object are defined as follows:

IAsyncResult BeginRead(byte[] buffer, int offset, int count,                       AsyncCallback callback, object state);int EndRead(IAsyncResult asyncResult);

The BeginRead method takes all the required parameters ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.