Summary

Taking advantage of multicore machines is becoming increasingly important. From a programmer’s point of view, various facilities in the System.Threading libraries make it easier to do so.

In this chapter, we explored the notion of task parallelism centered around the Task and Task<TResult> types. We discussed how to create tasks, await their results, work with continues, and deal with various aspects such as errors and cancellation. In summary, tasks are the new means to perform work asynchronously, whether it’s long running (where you’d have used threads before) or more ad hoc short-lived computations (using thread pools before). We also discussed how the task scheduler works, layered atop of the improved thread pool, employing techniques ...

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.