Creating an Asynchronous HTTP Get activity

The WebRequest class enables us to make an HTTP request in code. Usually, every WebRequest call requires some time span—several seconds or even minutes. If there is only one request, we can wait for the response. But what are we going to do if we have to make more requests, say 100—every request uses several seconds, and so 100 requests will hang our program.

Then we come up with a good idea: why not use multiple threads with one request for each thread? But it is quite expensive to initialize a thread. If one is writing.NET-managed code, each thread will take up 1MB memory and so 100 threads will use up 100MB memory! Apparently, multiple threads are not an option. So what should we do? In this task, ...

Get Microsoft Windows Workflow Foundation 4.0 Cookbook 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.