.NET 4.5 Parallel Extensions Cookbook

.NET 4.5 Parallel Extensions Cookbook
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 20%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Create multithreaded applications using .NET Framework 4.5
  • Get introduced to .NET 4.5 parallel extensions and familiarized with .NET parallel loops
  • Use new data structures introduced by .NET Framework 4.5 to simplify complex synchronisation problems
  • Practical recipes on everything you will need to create task-based parallel programs

Book Details

Language : English
Paperback : 336 pages [ 235mm x 191mm ]
Release Date : July 2013
ISBN : 1849690227
ISBN 13 : 9781849690225
Author(s) : Bryan Freeman
Topics and Technologies : All Books, Application Development, Cookbooks

Table of Contents

Chapter 1: Getting Started with Task Parallel Library
Chapter 2: Implementing Continuations
Chapter 3: Learning Concurrency with Parallel Loops
Chapter 4: Parallel LINQ
Chapter 5: Concurrent Collections
Chapter 6: Synchronization Primitives
Chapter 7: Profiling and Debugging
Chapter 8: Async
Chapter 9: Dataflow Library
  • Chapter 1: Getting Started with Task Parallel Library
    • Introduction
    • Creating a task
    • Waiting for tasks to finish
    • Returning results from a task
    • Passing data to a task
    • Creating a child task
    • Lazy task execution
    • Handling task exceptions using try/catch block
    • Handling task exceptions with AggregateException.Handle
    • Cancelling a task
    • Cancelling one of many tasks
    • Chapter 2: Implementing Continuations
      • Introduction
      • Continuing a task
      • Passing task results to a continuation
      • Continue "WhenAny" and "WhenAll"
      • Specifying when a continuation will run
      • Using a continuation for exception handling
      • Cancelling a continuation
      • Using a continuation to chain multiple tasks
      • Using a continuation to update a UI
      • Chapter 3: Learning Concurrency with Parallel Loops
        • Introduction
        • Creating a basic parallel for loop
        • Creating a basic parallel foreach loop
        • Breaking a parallel loop
        • Stopping a parallel loop
        • Cancelling a parallel loop
        • Handling exceptions in a parallel loop
        • Controlling the degree of parallelism in a loop
        • Partitioning data in a parallel loop
        • Using Thread Local Storage
        • Chapter 4: Parallel LINQ
          • Introduction
          • Creating a basic parallel query
          • Preserving order in parallel LINQ
          • Forcing parallel execution
          • Limiting parallelism in a query
          • Processing query results
          • Specifying merge options
          • Range projection with parallel LINQ
          • Handling exceptions in parallel LINQ
          • Cancelling a parallel LINQ query
          • Performing reduction operations
          • Creating a custom partitioner
          • Chapter 5: Concurrent Collections
            • Introduction
            • Adding and removing items to BlockingCollection
            • Iterating a BlockingCollection with GetConsumingEnumerable
            • Performing LIFO operations with ConcurrentStack
            • Thread safe data lookups with ConcurrentDictionary
            • Cancelling an operation in a concurrent collection
            • Working with multiple producers and consumers
            • Creating object pool with ConcurrentStack
            • Adding blocking and bounding with IProducerConsumerCollection
            • Using multiple concurrent collections to create a pipeline
            • Chapter 6: Synchronization Primitives
              • Introduction
              • Using monitor
              • Using a mutual exclusion lock
              • Using SpinLock for synchronization
              • Interlocked operations
              • Synchronizing multiple tasks with a Barrier
              • Using ReaderWriterLockSlim
              • Using WaitHandles with Mutex
              • Waiting for multiple threads with CountdownEvent
              • Using ManualResetEventSlim to spin and wait
              • Using SemaphoreSlim to limit access
              • Chapter 7: Profiling and Debugging
                • Introduction
                • Using the Threads and Call Stack windows
                • Using the Parallel Stacks window
                • Watching values in a thread with Parallel Watch window
                • Detecting deadlocks with the Parallel Tasks window
                • Measure CPU utilization with Concurrency Visualizer
                • Using Concurrency Visualizer Threads view
                • Using Concurrency Visualizer Cores view
                • Chapter 8: Async
                  • Introduction
                  • Creating an async method
                  • Handling Exceptions in asynchronous code
                  • Cancelling an asynchronous operation
                  • Cancelling async operation after timeout period
                  • Processing multiple async tasks as they complete
                  • Improving performance of async solution with Task.WhenAll
                  • Using async for file access
                  • Checking the progress of an asynchronous task
                  • Chapter 9: Dataflow Library
                    • Introduction
                    • Reading from and writing to a dataflow block synchronously
                    • Reading from and writing to a dataflow block asynchronously
                    • Implementing a producer-consumer dataflow pattern
                    • Creating a dataflow pipeline
                    • Cancelling a dataflow block
                    • Specifying the degree of parallelism
                    • Unlink dataflow blocks
                    • How it works…
                    • Using JoinBlock to read from multiple data sources

                    Bryan Freeman

                    Bryan Freeman is a developer, architect, and writer on Parallel and Distributed Technologies. With over 15 years of experience delivering solutions across industry sectors such as healthcare, finance, and transportation, he specializes in technologies such as Microsoft .NET, Windows Communication Foundation, Windows Workflow, and Windows Azure to help clients deliver business value and drive revenue while reducing operational costs. As an active speaker, writer, and blogger, Bryan is a passionate community advocate for those who develop solutions based on .NET technologies. He is also an active member of the Scottsdale Institute and the Veterans of Foreign Wars.

                    Code Downloads

                    Download the code and support files for this book.

                    Submit Errata

                    Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

                    Sample chapters

                    You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                    Frequently bought together

                    .NET 4.5 Parallel Extensions Cookbook +    Middleware Management with Oracle Enterprise Manager Grid Control 10g R5 =
                    50% Off
                    the second eBook
                    Price for both: £27.35

                    Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                    What you will learn from this book

                    • Create a task using Parallel.Invoke, Task.Factory, and Task.Start
                    • Work with declarative data parallelism using Parallel Language Integrated Query (PLINQ) and its aggregate functions
                    • Perform independent operations on the member data of a collection using parallel loops
                    • Coordinate the activities of multiple tasks using new lightweight synchronization primitives
                    • Learn to use Visual Studio 2012 debugging and profiling capabilities related to parallel programming
                    • Maintain a responsive UI using asynchronous tasks
                    • Create a pipeline using multiple concurrent collections

                    In Detail

                    .NET parallel extensions brings the power of parallel and asynchronous programming to a much wider developer audience than ever before. This book will give a developer with no multithreaded development experience the ability to write highly scalable parallel applications that take advantage of modern multicore processors.If you are an experienced .NET developer who wants to put parallel extensions to work in your applications, this book is for you.

                    ".NET 4.5 Parallel Extensions Cookbook" is a practical, hands-on guide that provides you with a number of clear step-by-step recipes that will introduce parallelism into your applications and take advantage of modern multicore processors. This book is a crash course in using the extensions, with theory and concepts kept to a minimum.

                    ".NET 4.5 Parallel Extensions Cookbook" offers a wide-ranging presentation of parallel development concepts, and provides a working knowledge of key technologies that are important to developers who want to take advantage of multi-core architectures.

                    You will learn how to compose a series of producer/consumer tasks into a pipeline that can process data elements received from a real-time event stream. You will also learn how to connect the stages of pipelines together using the concurrent collections. You will learn everything you need to know to transform the multicore power found in modern processors into application performance and scalability.


                    This book contains practical recipes on everything you will need to create task-based parallel programs using C#, .NET 4.5, and Visual Studio. The book is packed with illustrated code examples to create scalable programs.

                    Who this book is for

                    This book is intended to help experienced C# developers write applications that leverage the power of modern multicore processors. It provides the necessary knowledge for an experienced C# developer to work with .NET parallelism APIs. Previous experience of writing multithreaded applications is not necessary.

                    Code Download and Errata
                    Packt Anytime, Anywhere
                    Register Books
                    Print Upgrades
                    eBook Downloads
                    Video Support
                    Contact Us
                    Awards Voting Nominations Previous Winners
                    Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                    Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software