An Asynchronous Request/Response Pattern

Until now, all of our focus has been on using the networking classes in a synchronous fashion. However, the Internet itself is asynchronous in nature, and there are many programming tasks that are not well served by synchronous software design. In this section, we'll look at a design pattern for implementing an asynchronous request/response model using the WebRequest and WebResponse classes.

Overview

First, let's talk through a scenario: You want to issue a request for a Web page from a server. After the request has been made, your application should continue without waiting for the response. Once the response comes back, your application should be signaled somehow, so that it can now deal with the data ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.