Sorry this is taking so long. Something might have gone wrong. Please try reloading.


Solid Async in .NET

4 Days
.Net, Async, C++

Description

Solid Async Programming takes you through the core skills required to be successful developing async and multithreaded code both in the .NET and web worlds. Not only do we cover the core APIs but also how they are used effectively, tested and debugged.

This course was written by Andrew Clymer and Richard Blewett authors of the highly regarded Asynchronous Programming in .NET book by Apress.

Modules in Solid Async in .NET:

Tasks

When the Parallel Framework Extensions (PFx) were first announced it looked as though it was going to target a narrow set of requirements around parallelizing processor intensive code. Over time the scope of the library has grown significantly such that it has become the main model for building asynchronous code. The pivotal type enabling this transition is the Task class. This is a, functionally, very rich type allowing the creation of both short and long lived asynchronous work. Tasks can have dependencies on one another and support cancellation. In this, the first of the PFx modules we look, specifically, how this class gives us a unified framework for building multi-threaded code.

Thread Safety

Asynchronous programming requires careful attention to detail because most objects are not designed with multi-threaded access in mind. This module introduces core primitives provided by .NET such as Interlocked, Monitors and Reader-Writer locks. We will see that writing effective multi-threaded code is a balancing act between ensuring against data corruption while allowing as much concurrency as possible.

Simplifying Thread Safety

When developing multi­‐threaded, we need to consider  thread safety when sharing state across multiple threads. These techniques require the developer to understand possible race conditions and select the cheapest  synchronisation technique to satisfy thread safety. However, while this process is essential, it can often become tedious and can make even simple algorithms seem overly complex and hard to maintain. In this module, we will explore the use of framework provided concurrent data structures shipped with the Task Parallel Library that will simplify multi‐threaded code while maximising concurrency and efficiency.

Parallel Patterns with Pfx

The initial goal of PFx was to simplify the parallelization of processor intensive tasks - and this remains a key feature. In this module we will look at a variety of parallel programming patterns to solve various compute intensive tasks that use multiple CPUs using Parallel.For, Parallel.ForEach and PLinq.   

C# Async Await

C# 5 builds on the Task API introducing the async and await keywords. These bring asynchronous execution as a first class concept in the C# language. The new keywords create a very elegant model for all sorts of async work. This module will cover the simple uses cases, the most common gotcha's and then provide a deep dive into how these keywords work under the covers.

Server Side Asynchronous programming

The nature of server side applications often means they are asynchronous by their very design, servicing many clients at the same time on different threads. But as you dig deeper you often find these threads performing long running blocking operations – particularly in terms of IO - resulting in the consumption of more threads (an expensive resource) than necessary.  This module focuses on a range of server side technologies and demonstrates how to perform maximum concurrency for least number of threads.

TPL Dataflow

TPL Dataflow is a downloadable addition to the Task Parallel Library (TPL) that ships with the .NET framework. It provides an alternative approach to defining concurrency. Instead of just simply throwing threads at a synchronously structured programming and having to deal with all the thread safety and race conditions that are introduced as a result; we have the concept of many autonomous objects each with its own thread of execution. These autonomous objects co-operate with other such objects through asynchronous message passing. In this talk we will see how TPL Dataflow can greatly reduce the complexity normally associated with asynchronous programming.

Reactive Framework

The Reactive Framework Extensions (Rx) is a new library that uses the .NET 4.0 IObservable interface and LINQ to create a compelling new programming model that allows you to build "event" based code with declarative LINQ statements. This module introduces the Reactive Framework and shows how it can greatly simplify your code.

SignalR

SignalR is a framework for building asynchronous web applications. SignalR consists of two parts: a server and client that work together to produce a truly duplex bi-directional model for exchanging data. The server code is built along similar lines to Microsoft's ASP.Net MVC framework while the client will use the best technology available to do it's work, that could be Web Sockets, Ajax long polling, forever frame or Server Sent Events. Anywhere that you need to use asynchronous updates to multiple clients SignalR can help. We will cover how to set up and initialise SignalR and how to use it to call into the browser and get the browser to show updates.

Debugging Async

Debugging asynchronous code is hard as the execution is inherently non­‐deterministic in nature – the sequencing of instructions across independently scheduled threads can introduce hard to track down race conditions, state corruption and deadlocks.  In this module we look at tooling and techniques, both inside and outside Visual Studio, to assist you in tracking down those elusive Heisenbugs.