Asynchronous Programming

In the previous section, we were explicitly creating threads and managing their lifetime. In this section, we let the common language runtime do the grungy work for us.

Under the .NET asynchronous programming model, when a call is made to a .NET class method, the call returns immediately. The common language runtime sets up the actual method to be executed in a different thread. This makes it possible for the calling thread to continue forward with its execution. Contrast this to the synchronous programming model where the call blocks until the method is completely processed.

Once the method execution completes, the common language runtime provides two ways to obtain the results of the execution. You can call a specific ...

Get .NET Programming: A Practical Guide Using C# 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.