5.4. Tasks

Task is a new class that represents the work you want completed. There are methods to create, schedule, and synchronize tasks in your application.

5.4.1. Task Scheduler

All the complexity of working with tasks is handled by the task scheduler, which in turn works with the main .NET thread pool. You can think of a task as a wrapper for the thread pool and the preferred way of scheduling threads (although there is some additional overhead). The existing thread pool methods will continue to work, but tasks are much easier to use and have additional functionality.

So how does the task scheduler work?

  • When tasks are created, they are added to a global task queue.

  • The thread pool will create a number of "worker" threads. The exact number ...

Get Introducing .NET 4.0: with Visual Studio 2010 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.