0%

Book Description

If you’re an experienced C# developer, this book will give you the know-how to exploit the power of multicore processors. Its 80 recipes provide an in-depth guide to using .NET 4.5 to enhance application performance and scalability.

  • 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

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.

Table of Contents

  1. .NET 4.5 Parallel Extensions Cookbook
    1. Table of Contents
    2. .NET 4.5 Parallel Extensions Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting Started with Task Parallel Library
      1. Introduction
      2. Creating a task
        1. How to do it…
        2. How it works…
      3. Waiting for tasks to finish
        1. How to do it…
        2. How it works…
      4. Returning results from a task
        1. How to do it…
        2. How it works…
      5. Passing data to a task
        1. How to do it…
        2. How it works…
      6. Creating a child task
        1. How to do it…
        2. How it works…
      7. Lazy task execution
        1. How to do it…
        2. How it works…
      8. Handling task exceptions using try/catch block
        1. Getting ready…
        2. How to do it…
        3. How it works…
      9. Handling task exceptions with AggregateException.Handle
        1. Getting ready…
        2. How to do it…
        3. How it works…
      10. Cancelling a task
        1. How to do it…
        2. How it works…
        3. There's more…
      11. Cancelling one of many tasks
        1. How to do it…
        2. How it works…
    9. 2. Implementing Continuations
      1. Introduction
      2. Continuing a task
        1. How to do it…
        2. How it works…
      3. Passing task results to a continuation
        1. How to do it…
        2. How it works…
      4. Continue "WhenAny" and "WhenAll"
        1. How to do it…
        2. How it works…
      5. Specifying when a continuation will run
        1. How to do it…
        2. How it works…
        3. There's more…
      6. Using a continuation for exception handling
        1. Getting Ready
        2. How to do it…
        3. How it works…
      7. Cancelling a continuation
        1. Getting Ready
        2. How to do it…
        3. How it works…
      8. Using a continuation to chain multiple tasks
        1. How to do it…
        2. How it works…
      9. Using a continuation to update a UI
        1. How to do it…
        2. How it works…
    10. 3. Learning Concurrency with Parallel Loops
      1. Introduction
      2. Creating a basic parallel for loop
        1. How to do it…
        2. How it works…
      3. Creating a basic parallel foreach loop
        1. How to do it…
        2. How it works…
      4. Breaking a parallel loop
        1. How to do it…
        2. How it works…
      5. Stopping a parallel loop
        1. How to do it…
        2. How it works…
      6. Cancelling a parallel loop
        1. How to do it…
        2. How it works…
      7. Handling exceptions in a parallel loop
        1. Getting ready…
        2. How to do it…
        3. How it works…
      8. Controlling the degree of parallelism in a loop
        1. How to do it…
        2. How it works…
      9. Partitioning data in a parallel loop
        1. How to do it…
        2. How it works…
      10. Using Thread Local Storage
        1. How to do it…
        2. How it works…
    11. 4. Parallel LINQ
      1. Introduction
      2. Creating a basic parallel query
        1. How to do it…
        2. How it works…
      3. Preserving order in parallel LINQ
        1. How to do it…
        2. How it works…
      4. Forcing parallel execution
        1. How to do it…
        2. How it works…
      5. Limiting parallelism in a query
        1. How to do it…
        2. How it works…
      6. Processing query results
        1. How to do it…
        2. How it works…
      7. Specifying merge options
        1. How to do it…
        2. How it works…
      8. Range projection with parallel LINQ
        1. How to do it…
        2. How it works…
      9. Handling exceptions in parallel LINQ
        1. Getting ready…
        2. How to do it…
        3. How it works…
      10. Cancelling a parallel LINQ query
        1. Getting ready…
        2. How to do it…
        3. How it works…
      11. Performing reduction operations
        1. How to do it…
        2. How it works…
      12. Creating a custom partitioner
        1. How to do it…
        2. How it works…
    12. 5. Concurrent Collections
      1. Introduction
      2. Adding and removing items to BlockingCollection
        1. How to do it…
        2. How it works…
      3. Iterating a BlockingCollection with GetConsumingEnumerable
        1. How to do it…
        2. How it works…
      4. Performing LIFO operations with ConcurrentStack
        1. How to do it…
        2. How it works…
      5. Thread safe data lookups with ConcurrentDictionary
        1. How to do it…
        2. How it works…
      6. Cancelling an operation in a concurrent collection
        1. Getting ready…
        2. How to do it…
        3. How it works…
      7. Working with multiple producers and consumers
        1. How to do it…
        2. How it works…
      8. Creating object pool with ConcurrentStack
        1. How to do it…
        2. How it works…
      9. Adding blocking and bounding with IProducerConsumerCollection
        1. How to do it…
        2. How it works…
      10. Using multiple concurrent collections to create a pipeline
        1. How to do it…
        2. How it works…
    13. 6. Synchronization Primitives
      1. Introduction
      2. Using monitor
        1. How to do it…
        2. How it works…
      3. Using a mutual exclusion lock
        1. How to do it…
        2. How it works…
      4. Using SpinLock for synchronization
        1. How to do it…
        2. How it works…
      5. Interlocked operations
        1. How to do it…
        2. How it works…
      6. Synchronizing multiple tasks with a Barrier
        1. How to do it…
        2. How it works…
      7. Using ReaderWriterLockSlim
        1. How to do it…
        2. How it works…
      8. Using WaitHandles with Mutex
        1. How to do it…
        2. How it works…
      9. Waiting for multiple threads with CountdownEvent
        1. How to do it…
        2. How it works…
      10. Using ManualResetEventSlim to spin and wait
        1. How to do it…
        2. How it works…
      11. Using SemaphoreSlim to limit access
        1. How to do it…
        2. How it works…
    14. 7. Profiling and Debugging
      1. Introduction
      2. Using the Threads and Call Stack windows
        1. Getting ready…
        2. How to do it…
      3. Using the Parallel Stacks window
        1. How to do it…
      4. Watching values in a thread with Parallel Watch window
        1. How to do it…
      5. Detecting deadlocks with the Parallel Tasks window
        1. Getting ready…
        2. How to do it…
      6. Measure CPU utilization with Concurrency Visualizer
        1. Getting ready…
        2. How to do it…
      7. Using Concurrency Visualizer Threads view
        1. Getting ready…
        2. How to do it…
      8. Using Concurrency Visualizer Cores view
        1. Getting ready…
        2. How to do it…
    15. 8. Async
      1. Introduction
      2. Creating an async method
        1. How to do it…
        2. How it works…
      3. Handling Exceptions in asynchronous code
        1. How to do it…
        2. How it works…
      4. Cancelling an asynchronous operation
        1. How to do it…
        2. How it works…
      5. Cancelling async operation after timeout period
        1. How to do it…
        2. How it works…
      6. Processing multiple async tasks as they complete
        1. How to do it…
        2. How it works…
      7. Improving performance of async solution with Task.WhenAll
        1. How to do it…
        2. How it works…
      8. Using async for file access
        1. How to do it…
        2. How it works…
      9. Checking the progress of an asynchronous task
        1. How to do it…
        2. How it works…
    16. 9. Dataflow Library
      1. Introduction
      2. Reading from and writing to a dataflow block synchronously
        1. Getting ready…
        2. How to do it…
        3. How it works…
      3. Reading from and writing to a dataflow block asynchronously
        1. How to do it…
        2. How it works…
      4. Implementing a producer-consumer dataflow pattern
        1. How to do it…
        2. How it works…
      5. Creating a dataflow pipeline
        1. How to do it…
        2. How it works…
      6. Cancelling a dataflow block
        1. How to do it…
        2. How it works…
      7. Specifying the degree of parallelism
        1. How to do it…
        2. How it works…
      8. Unlink dataflow blocks
        1. How to do it…
        2. How it works…
      9. Using JoinBlock to read from multiple data sources
        1. How to do it…
        2. How it works…
    17. Index
18.116.51.117