O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

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

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, ...

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