T1303

Ladda ner som PDF

Parallel and Asynchronous Programming in C#

In recent years, parallel hardware has become the norm. It's not unusual to discover that one's smartphone has a multi-core CPU these days! At the same time, making calls to remote services has become common and users have come to expect highly responsive interfaces - both of which push developers towards asynchronous programming.

Prior knowledge

This course assumes participants are already comfortable C# developers. The topics and libraries it covers make very frequent use of generics, lambdas and LINQ. Therefore, it is advisable to have a reasonable knowledge of these C# language features before taking the course. On the other hand, prior experience with parallel and asynchronous programming is not required.

Language

The course is taught in English (Contact us if you prefer Swedish).

Courseware

Course material in English included.

Informator Training Cloud

Our training portal supports your development throughout the training. The portal saves you time and is designed to give you a more effective learning experience - leading to better results and greater knowledge enforcement after the course. Read more >

Thankfully, the .Net Framework and C# language have been evolving to help us cope with these new realities and expectations. Of course, there have always been threads and locks - but today, we've many, many more options: concurrent collections, parallel looping constructs, PLINQ, Tasks, the new async/await keywords in C# 5, the Reactive Extensions (Rx), the TPL Dataflow library with its Actor-based approach... Each of them are suitable for different problems. So how do you know what to use when, and how to use them effectively?

That's where this course comes in. It won't just teach you how to use all of these exciting new libraries. It will also help you to understand what kind of problem each one is aimed at, so that you can pick the appropriate solution to the challenges you face. It also provides clear explanations of pertinent theory and terminology, including a dive all the way down to the hardware level, so you'll have a strong grasp on what's really going on! Labs will provide an opportunity for you to try things out for yourself.

Course outline:

Day 1

Classifying Concurrency

  • Parallel vs. asynchronous
  • Task parallel vs. data parallel
  • CPU-bound vs. IO-bound
  • Shared vs. thread-local data
  • Blocking, lock-free, wait-free, and progress bounds

Understanding The Hardware

  • Why did CPUs go multi-core?
  • How CPU caches work with multi-core, and why it matters
  • Why... Läs mer

Thankfully, the .Net Framework and C# language have been evolving to help us cope with these new realities and expectations. Of course, there have always been threads and locks - but today, we've many, many more options: concurrent collections, parallel looping constructs, PLINQ, Tasks, the new async/await keywords in C# 5, the Reactive Extensions (Rx), the TPL Dataflow library with its Actor-based approach... Each of them are suitable for different problems. So how do you know what to use when, and how to use them effectively?

That's where this course comes in. It won't just teach you how to use all of these exciting new libraries. It will also help you to understand what kind of problem each one is aimed at, so that you can pick the appropriate solution to the challenges you face. It also provides clear explanations of pertinent theory and terminology, including a dive all the way down to the hardware level, so you'll have a strong grasp on what's really going on! Labs will provide an opportunity for you to try things out for yourself.

Course outline:

Day 1

Classifying Concurrency

  • Parallel vs. asynchronous
  • Task parallel vs. data parallel
  • CPU-bound vs. IO-bound
  • Shared vs. thread-local data
  • Blocking, lock-free, wait-free, and progress bounds

Understanding The Hardware

  • Why did CPUs go multi-core?
  • How CPU caches work with multi-core, and why it matters
  • Why therad-local storage helps
  • Why immutability helps
  • The problem of false sharing

Building Blocks

  • Threads
  • How many threads?
  • The thread pool
  • The Task abstraction

Locking

  • Monitors, the lock keyword
  • Multiple Reader, Single Writer locks
  • Deadlock
  • Lock granularity
  • The cost of locking
  • Avoiding locking

Concurrent Collections

  • What are the concurrent collections?
  • Concurrent queues, stacks, bags and dictionaries
  • The blocking collection
  • Queues and Staged Event Driven Architecture
  • Other use cases
  • Performance compared to locking the non-concurrent collections

The Parallel Class

  • Parallel for
  • Parallel foreach
  • Flow control in parallel loops
  • Keeping thread local state in parallel loops
  • Exceptions and parallel loops
  • Cancellation
  • Parallel invoke

Day 2

Asynchronous Programming

  • Why threads aren't ideal for blocking operations
  • ContinueWith and CPS (Continuation Passing Style)
  • Why CPS transforms hurt, and how async/await help
  • Exploring the new Async methods in .Net 4.5
  • Task combinators

More On Asynchrony

  • Understanding synchronization contexts
  • Cancellation
  • Task completion sources
  • Integrating asynchrony and parallelism

Introducing Rx

  • The Enumerable/Observable duality
  • IObserver and IObservable
  • Producing and consuming simple event streams
  • Subscription and unsubscription
  • Familiar Linq Operators, the Rx way
  • Converting enumerables to observables, and vice versa

Applying Rx

  • Using Rx with Windows Forms
  • Using Rx with WPF
  • Using Rx with async/await
  • Understanding schedulers
  • Writing tests for Rx code
  • Other useful Rx bits

Day 3

TPL DataFlow

  • Agents and actors: the ideas behind dataflow parallelism
  • Sources, targets and propagators
  • Transforming
  • Joining
  • Batching
  • Schedulers
  • Implementing custom blocks

Parallel LINQ

  • A quick LINQ refresher
  • Using PLINQ
  • Understanding how PLINQ parallelizes queries
  • Order (non-)preservation
  • Merge options
  • Cancellation
  • Dealing with exceptions
  • Custom aggregation functions

Atomic Operations and Lock Free Data Structures

  • The Interlocked class
  • Basic atomic operations
  • Atomic Compare And Swap (CAS)
  • How to make any data structure lock free - at a cost
  • Livelock, and the contrast with wait freedom
  • The A-B problem

Putting It All Together

  • Mapping problems to suitable concurrent mechanisms
  • Integrating approaches
  • The importance of immutability
  • Trends so far, and how the future may look
"Mycket bra innehåll och bra kursledare." 
/ en nöjd deltagare 14/1-2015
Citat från tidigare deltagare

 

 

 

Utbildningen levereras i samarbete med

Kurs-ID: T1303
Längd: 3 dagar
Pris exkl moms: 26 950 kr

Frågor om kursen?

Har du frågor om kursens innehåll, leveransdatum/ort eller behöver en företagsanpassad variant? Fyll i formuläret nedan!


Kan betalas med:
TRAINING CARD

Ort och datum

Stockholm
13 dec-15 dec
Boka nu!
23 jan-25 jan
Boka nu!
22 mar-24 mar
Boka nu!
15 maj-17 maj
Boka nu!
Göteborg
13 dec-15 dec R
Boka nu!
23 jan-25 jan R
Boka nu!
22 mar-24 mar R
Boka nu!
15 maj-17 maj R
Boka nu!
Malmö
13 dec-15 dec R
Boka nu!
23 jan-25 jan R
Boka nu!
22 mar-24 mar R
Boka nu!
15 maj-17 maj R
Boka nu!
Cloud Access
i Läs mer

Delta på kursen från ditt hem, jobb eller annan plats.

13 dec-15 dec
Boka nu!
23 jan-25 jan
Boka nu!
22 mar-24 mar
Boka nu!
15 maj-17 maj
Boka nu!

Tipsa