SlideShare a Scribd company logo
1 of 42
Download to read offline
www.xedotnet.org
Surviving in an Async-First
Development World
Mirco Vanini

Microsoft® MVP Windows Development
AllSeen Alliance - AllJoyn® Ambassador
OCF® Members
Genesis
Keywords
Costs of Async and Await
Understanding the Keywords
Context
Benefit of Asynchrony
Avoid async void
Threadpool
Configure context
24/03/17 2
Agenda
24/03/17 3
Genesis
using (var sr = new StreamReader("text.txt"))
{
    var content = sr.ReadToEnd();
}
24/03/17 3
Genesis
using (var sr = new StreamReader("text.txt"))
{
    var content = sr.ReadToEnd();
}
Thread wkThread = new Thread(new ThreadStart(ReadFileText)
);
wkThread.Start();
24/03/17 3
Genesis
using (var sr = new StreamReader("text.txt"))
{
    var content = sr.ReadToEnd();
}
Thread wkThread = new Thread(new ThreadStart(ReadFileText)
);
wkThread.Start();
private delegate void NoParamDelegate();
 
NoParamDelegate npd = new NoParamDelegate(ReadFileTex
t);
npd.BeginInvoke(new AsyncCallback(CallBack), null);
24/03/17 3
Genesis
using (var sr = new StreamReader("text.txt"))
{
    var content = sr.ReadToEnd();
}
Thread wkThread = new Thread(new ThreadStart(ReadFileText)
);
wkThread.Start();
private delegate void NoParamDelegate();
 
NoParamDelegate npd = new NoParamDelegate(ReadFileTex
t);
npd.BeginInvoke(new AsyncCallback(CallBack), null);
Task.Factory.StartNew(() =>
{
    using (StreamReader sr = new StreamReader("text.tx
t"))
    {
        return sr.ReadToEnd();
    }
}).ContinueWith((t) => t.Result     
    // UI update
);
24/03/17 4
Introducing the Keywords
public async Task DoSomethingAsync()
{
// In the Real World, we would actually do something...
// For this example, we're just going to (asynchronously)
// wait 100ms.
//
await Task.Delay(100);
}
The async and await keywords in C# are the heart of async programming.
By using those two keywords, you can use resources in the .NET Framework or the
Windows
Runtime to create an asynchronous method almost as easily as you create a
synchronous
method. Asynchronous methods that you define by using  async  and  await  are
referred
to as async methods.
24/03/17 5
What Happens in an Async
Method
24/03/17 6
Question: How it works?
Task delayTask = Task.Delay(TimeSpan.FromSecond(2));


var httpClient = new HttpClient();
Task<string> downlaodTask = httpClient.GetStringAsync(htt
p://www.example.com);
24/03/17 7
Understanding the Costs of Async and
Await
public static async Task SimpleBodyAsync() 
{
Console.WriteLine("Hello, Async World!");
}
24/03/17 7
Understanding the Costs of Async and
Await
public static async Task SimpleBodyAsync() 
{
Console.WriteLine("Hello, Async World!");
}
[DebuggerStepThrough]     
public static Task SimpleBodyAsync() {
  <SimpleBodyAsync>d__0 d__ = new <SimpleBodyAsync>d__0
();
  d__.<>t__builder = AsyncTaskMethodBuilder.Create();
  d__.MoveNext();
  return d__.<>t__builder.Task;
}
 
[CompilerGenerated]
[StructLayout(LayoutKind.Sequential)]
private struct <SimpleBodyAsync>d__0 : <>t__IStateMachi
ne {
  private int <>1__state;
  public AsyncTaskMethodBuilder <>t__builder;
  public Action <>t__MoveNextDelegate;
 
  public void MoveNext() {
    try {
      if (this.<>1__state == -1) return;
      Console.WriteLine("Hello, Async World!");
    }
    catch (Exception e) {
      this.<>1__state = -1;
      this.<>t__builder.SetException(e);
      return;
    }
 
    this.<>1__state = -1;
    this.<>t__builder.SetResult();
  }
 
  ...
}
24/03/17 8
Understanding the Keywords
• The “async” keyword enables the “await” keyword in
that method and changes how method results are
handled. That’s all the async keyword does! It does not
run this method on a thread pool thread, or do any
other kind of magic. The async keyword  only  enables
the await keyword (and manages the method results).
• The “await” keyword is where things can get
asynchronous. Await is like a unary operator: it takes a
single argument, an  awaitable  (an “awaitable” is an
asynchronous operation). Await examines that awaitable
to see if it has already completed; if the awaitable has
already completed, then the method just continues
running (synchronously, just like a regular method).
24/03/17 9
Context
• When you await a built-in awaitable, then the
awaitable will capture the current “context” and
later apply it to the remainder of the async
method
• If you’re on a UI thread, then it’s a UI context.
• If you’re responding to an ASP.NET request, then it’s an
ASP.NET request context.
• Otherwise, it’s usually a thread pool context.
24/03/17 10
Benefit of Asynchrony
• Free up threads
• This is the opposite of "creating more threads
" or "using a thread pool thread "
24/03/17 11
Avoid Async Void
• There are three possible return types for async
methods: Task, Task<T> and void.
• Void-returning async methods have a specific
purpose: to make asynchronous event handlers
possible
• When converting from synchronous to
asynchronous code, any method returning a
type T becomes an async method returning
Task<T>, and any method returning void
becomes an async method returning Task
Demo
18/11/16 12
Step 1
Step 2
24/03/17 13
Avoid Async Void
• Async void is a “fire-and-forget” mechanism...
• The caller is unable to know when an async void
has finished
• The caller is unable to catch exceptions thrown
from an async void
• Use async void methods only for top-level event
handlers (and their like)
• Use async Task-returning methods everywhere else
If you need fire-and-forget elsewhere, indicate it
explicitly e.g. “FredAsync().FireAndForget()”
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
Avoid Async Void
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
class LayoutAwarePage : Page
{
private string _pageKey;
protected override void OnNavigatedTo(NavigationEventArgs
e)
{
if (this._pageKey != null) return;
this._pageKey = "Page-" + this.Frame.BackStackDepth;
...
this.LoadState(e.Parameter, null);
}
}
Avoid Async Void
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
Avoid Async Void
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
Avoid Async Void
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
Avoid Async Void
24/03/17 14
// Q. It sometimes shows PixelWidth and PixelHeight are both 0 ???
BitmapImage m_bmp;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
image1.Source = m_bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth);
}
protected override async void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmp = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///
pic.png");
using (var stream = await file.OpenReadAsync()) {
await m_bmp.SetSourceAsync(stream);
}
}
Avoid Async Void
24/03/17 15
Avoid Async Void
// A. Use a task
Task<BitmapImage> m_bmpTask;
protected override async void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
await PlayIntroSoundAsync();
var bmp = await m_bmpTask; image1.Source = bmp;
Canvas.SetLeft(image1, Window.Current.Bounds.Width - bmp.PixelWidth);
}
protected override void LoadState(Object nav, Dictionary<String, Object>
pageState) {
m_bmpTask = LoadBitmapAsync();
}
private async Task<BitmapImage> LoadBitmapAsync() {
var bmp = new BitmapImage();
...
return bmp;
}
24/03/17 16
Threadpool
// table1.DataSource = LoadHousesSequentially(1,5);
// table1.DataBind();
public List<House> LoadHousesSequentially(int first, int
last)
{
var loadedHouses = new List<House>();
for (int i = first; i <= last; i++) {
House house = House.Deserialize(i);
loadedHouses.Add(house);
}
return loadedHouses;
}
24/03/17 16
Threadpool
work1
request in
response out

500ms
work2
work3
work4
work5
24/03/17 17
Threadpool
// table1.DataSource = LoadHousesInParallel(1,5);
// table1.DataBind();
public List<House> LoadHousesInParallel(int first, int last)
{
var loadedHouses = new BlockingCollection<House>();
Parallel.For(first, last+1, i => {
House house = House.Deserialize(i);
loadedHouses.Add(house);
});
return loadedHouses.ToList();
}
24/03/17 17
Threadpool
1 2
3
4
5
Parallel.Forrequest in
24/03/17 17
Threadpool
response out

300ms
work1 work2
work3 work4
work5
Parallel.Forrequest in
24/03/17 17
Threadpool
response out

300ms
work1 work2
work3 work4
work5
Parallel.Forrequest in
Is it CPU-
bound,

or I/O-bound?
24/03/17 17
Threadpool
response out

300ms
work1 work2
work3 work4
work5
Parallel.Forrequest in
24/03/17 18
Threadpool
// table1.DataSource = await LoadHousesAsync(1,5);
// table1.DataBind();
public async Task<List<House>> LoadHousesAsync(int first, int
last)
{
var tasks = new List<Task<House>>();
for (int i = first; i <= last; i++)
{
Task<House> t = House.LoadFromDatabaseAsync(i);
tasks.Add(t);
}
House[] loadedHouses = await Task.WhenAll(tasks);
return loadedHouses.ToList();
}
24/03/17 18
Threadpool
start1
request in
start2
start3
start4
start5
24/03/17 18
Threadpool
end2
start1
request in
start2
start3
start4
start5
response out

~100ms
end5
end1
end3
end4
24/03/17 19
Threadpool
• CPU-bound work means things like: LINQ-over-
objects, or big iterations, or computational inner
loops.
• Parallel.ForEach and Task.Run are a good way to
put CPU-bound work onto the thread pool.
• Use of threads will never increase throughput on a
machine that’s under load.
• For IO-bound “work”, use await rather than
background threads.
• For CPU-bound work, consider using background
threads via Parallel.ForEach or Task.Run, unless
you're writing a library, or scalable server-side
code.
24/03/17 20
Reactive Multithreaded
Asynchronous Parallel
Concurrent
Concurrent mode
24/03/17 21
Configure Context
• The “context” is captured by default when an
incomplete Task is awaited, and that this captured
context is used to resume the async method
• Most of the time, you don’t need to sync back to
the “main” context ! Most async methods will be
designed with composition in mind.
• Awaiter not capture the current context by
calling ConfigureAwait
• Avoids unnecessary thread marshaling
• Code shouldn’t block UI thread, but avoids deadlocks if
it does
24/03/17 21
Configure Context
• The “context” is captured by default when an
incomplete Task is awaited, and that this captured
context is used to resume the async method
• Most of the time, you don’t need to sync back to
the “main” context ! Most async methods will be
designed with composition in mind.
• Awaiter not capture the current context by
calling ConfigureAwait
• Avoids unnecessary thread marshaling
• Code shouldn’t block UI thread, but avoids deadlocks if
it does
private async void DownloadFileButton_Click(object sender, EventArgs e)
{
// Since we asynchronously wait, the UI thread is not blocked by the file
download.
//
await DownloadFileAsync(fileNameTextBox.Text);
// Since we resume on the UI context, we can directly access UI elements.
//
resultTextBox.Text = "File downloaded!";
}
private async Task DownloadFileAsync(string fileName)
{
// Use HttpClient or whatever to download the file contents.
//
var fileContents = await
DownloadFileContentsAsync(fileName).ConfigureAwait(false);
// Note that because of the ConfigureAwait(false), we are not on the
// original context here.
// Instead, we're running on the thread pool.
// Write the file contents out to a disk file.
//
await WriteToDiskAsync(fileName, fileContents).ConfigureAwait(false);
// The second call to ConfigureAwait(false) is not *required*, but it is Good
Practice.
24/03/17 22
Async Console
• Unfortunately, that doesn’t work, the
compiler will reject an async Main method
• You can work around this by providing your
own async-compatible contex
class Program
{
  static async void Main(string[] args)
  {
    ...
  }
}
24/03/17 22
Async Console
• Unfortunately, that doesn’t work, the
compiler will reject an async Main method
• You can work around this by providing your
own async-compatible contex
class Program
{
  static async void Main(string[] args)
  {
    ...
  }
}
class Program
{
static int Main(string[] args)
{
try
{
return AsyncContext.Run(() => MainAsync(args));
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
return -1;
}
}
static async Task<int> MainAsync(string[] args)
{}
}
Console applications and Win32 services do not have a
suitable context,
and AsyncContext or AsyncContextThread could be used in
those situations.
24/03/17 23
Links
• Async and Await
• Async/Await - Best Practices in Asynchronous
Programming
• Async Performance: Understanding the Costs of
Async and Await
• Async programming deep dive
24/03/17 24
Who I am


www.adamfactory.com
mirco.vanini@adamfactory.com
@MircoVanini
Mirco Vanini
Microsoft® MVP Windows Development AllSeen
Alliance - AllJoyn® Ambassador
OCF® Member
TinyCLR.it

More Related Content

What's hot

Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsRobert Brown
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011Patrick Walton
 
Memory Management of C# with Unity Native Collections
Memory Management of C# with Unity Native CollectionsMemory Management of C# with Unity Native Collections
Memory Management of C# with Unity Native CollectionsYoshifumi Kawai
 
Core Java Programming Language (JSE) : Chapter XII - Threads
Core Java Programming Language (JSE) : Chapter XII -  ThreadsCore Java Programming Language (JSE) : Chapter XII -  Threads
Core Java Programming Language (JSE) : Chapter XII - ThreadsWebStackAcademy
 
CONFidence 2015: Trust boundaries - Mateusz Kocielski
CONFidence 2015: Trust boundaries - Mateusz KocielskiCONFidence 2015: Trust boundaries - Mateusz Kocielski
CONFidence 2015: Trust boundaries - Mateusz KocielskiPROIDEA
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Sachintha Gunasena
 
Basics of Java Concurrency
Basics of Java ConcurrencyBasics of Java Concurrency
Basics of Java Concurrencykshanth2101
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in PracticeAlina Dolgikh
 
Philly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJSPhilly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJSRoss Kukulinski
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneC4Media
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksStoyan Nikolov
 
Intro to data oriented design
Intro to data oriented designIntro to data oriented design
Intro to data oriented designStoyan Nikolov
 

What's hot (16)

Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
 
Rust-lang
Rust-langRust-lang
Rust-lang
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
Memory Management of C# with Unity Native Collections
Memory Management of C# with Unity Native CollectionsMemory Management of C# with Unity Native Collections
Memory Management of C# with Unity Native Collections
 
Core Java Programming Language (JSE) : Chapter XII - Threads
Core Java Programming Language (JSE) : Chapter XII -  ThreadsCore Java Programming Language (JSE) : Chapter XII -  Threads
Core Java Programming Language (JSE) : Chapter XII - Threads
 
CONFidence 2015: Trust boundaries - Mateusz Kocielski
CONFidence 2015: Trust boundaries - Mateusz KocielskiCONFidence 2015: Trust boundaries - Mateusz Kocielski
CONFidence 2015: Trust boundaries - Mateusz Kocielski
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
 
Basics of Java Concurrency
Basics of Java ConcurrencyBasics of Java Concurrency
Basics of Java Concurrency
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
 
Node.js code tracing
Node.js code tracingNode.js code tracing
Node.js code tracing
 
Philly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJSPhilly Tech Week Introduction to NodeJS
Philly Tech Week Introduction to NodeJS
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
 
Intro to data oriented design
Intro to data oriented designIntro to data oriented design
Intro to data oriented design
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 

Viewers also liked

Windows 10 IoT Core, a real sample
Windows 10 IoT Core, a real sampleWindows 10 IoT Core, a real sample
Windows 10 IoT Core, a real sampleMirco Vanini
 
IoT & Azure (EventHub)
IoT & Azure (EventHub)IoT & Azure (EventHub)
IoT & Azure (EventHub)Mirco Vanini
 
Fists with Your Toes - Learning to relax as a UX / BA crossbreed
Fists with Your Toes - Learning to relax as a UX / BA crossbreedFists with Your Toes - Learning to relax as a UX / BA crossbreed
Fists with Your Toes - Learning to relax as a UX / BA crossbreedLeo Barnes
 
Bucay, jorge el camino de la autodependencia
Bucay, jorge   el camino de la autodependenciaBucay, jorge   el camino de la autodependencia
Bucay, jorge el camino de la autodependenciasilvianoramirezgomez
 
Entrevista, grupo focal y diario de campo NRC30018
Entrevista, grupo focal y diario de campo NRC30018Entrevista, grupo focal y diario de campo NRC30018
Entrevista, grupo focal y diario de campo NRC30018John Sevastien
 
An introduction to english literature i
An introduction to english literature iAn introduction to english literature i
An introduction to english literature ipuchmuller
 
The Mysteries Of Harris Burdickfv
The Mysteries Of Harris BurdickfvThe Mysteries Of Harris Burdickfv
The Mysteries Of Harris Burdickfvaquaglia
 
Cloud in Action
Cloud in Action Cloud in Action
Cloud in Action Franco Ucci
 
Fitness tips for women
Fitness tips for womenFitness tips for women
Fitness tips for womenMedisys Kart
 
開発ツール管理者の羅針盤
開発ツール管理者の羅針盤開発ツール管理者の羅針盤
開発ツール管理者の羅針盤Dai FUJIHARA
 
The Dawn of the Suprasystem
The Dawn of the SuprasystemThe Dawn of the Suprasystem
The Dawn of the SuprasystemAna Soric
 
Instagram Analytics: What to Measure to Grow Your Instagram
Instagram Analytics: What to Measure to Grow Your InstagramInstagram Analytics: What to Measure to Grow Your Instagram
Instagram Analytics: What to Measure to Grow Your InstagramPeg Fitzpatrick
 
Автоматизация SEO-задач в 2017 — CyberMarketing — Севальнев
Автоматизация SEO-задач в 2017 — CyberMarketing — СевальневАвтоматизация SEO-задач в 2017 — CyberMarketing — Севальнев
Автоматизация SEO-задач в 2017 — CyberMarketing — СевальневДмитрий Севальнев
 
Pharos - Face of the KMC
Pharos - Face of the KMCPharos - Face of the KMC
Pharos - Face of the KMCRajarshi Guha
 

Viewers also liked (18)

Windows 10 IoT Core, a real sample
Windows 10 IoT Core, a real sampleWindows 10 IoT Core, a real sample
Windows 10 IoT Core, a real sample
 
IoT & Azure (EventHub)
IoT & Azure (EventHub)IoT & Azure (EventHub)
IoT & Azure (EventHub)
 
Portadas nacionales 30 marzo-17.pdf
Portadas nacionales 30 marzo-17.pdfPortadas nacionales 30 marzo-17.pdf
Portadas nacionales 30 marzo-17.pdf
 
Fists with Your Toes - Learning to relax as a UX / BA crossbreed
Fists with Your Toes - Learning to relax as a UX / BA crossbreedFists with Your Toes - Learning to relax as a UX / BA crossbreed
Fists with Your Toes - Learning to relax as a UX / BA crossbreed
 
Bucay, jorge el camino de la autodependencia
Bucay, jorge   el camino de la autodependenciaBucay, jorge   el camino de la autodependencia
Bucay, jorge el camino de la autodependencia
 
HdE - Spegulo
HdE - SpeguloHdE - Spegulo
HdE - Spegulo
 
Entrevista, grupo focal y diario de campo NRC30018
Entrevista, grupo focal y diario de campo NRC30018Entrevista, grupo focal y diario de campo NRC30018
Entrevista, grupo focal y diario de campo NRC30018
 
An introduction to english literature i
An introduction to english literature iAn introduction to english literature i
An introduction to english literature i
 
The Mysteries Of Harris Burdickfv
The Mysteries Of Harris BurdickfvThe Mysteries Of Harris Burdickfv
The Mysteries Of Harris Burdickfv
 
Cloud in Action
Cloud in Action Cloud in Action
Cloud in Action
 
Fitness tips for women
Fitness tips for womenFitness tips for women
Fitness tips for women
 
Introduction to Data Oriented Design
Introduction to Data Oriented DesignIntroduction to Data Oriented Design
Introduction to Data Oriented Design
 
開発ツール管理者の羅針盤
開発ツール管理者の羅針盤開発ツール管理者の羅針盤
開発ツール管理者の羅針盤
 
The Dawn of the Suprasystem
The Dawn of the SuprasystemThe Dawn of the Suprasystem
The Dawn of the Suprasystem
 
KPI driven growth
KPI driven growthKPI driven growth
KPI driven growth
 
Instagram Analytics: What to Measure to Grow Your Instagram
Instagram Analytics: What to Measure to Grow Your InstagramInstagram Analytics: What to Measure to Grow Your Instagram
Instagram Analytics: What to Measure to Grow Your Instagram
 
Автоматизация SEO-задач в 2017 — CyberMarketing — Севальнев
Автоматизация SEO-задач в 2017 — CyberMarketing — СевальневАвтоматизация SEO-задач в 2017 — CyberMarketing — Севальнев
Автоматизация SEO-задач в 2017 — CyberMarketing — Севальнев
 
Pharos - Face of the KMC
Pharos - Face of the KMCPharos - Face of the KMC
Pharos - Face of the KMC
 

Similar to Surviving in an Async-First Development World

200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis ExperienceAndrey Karpov
 
Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32Windows Developer
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second LanguageRob Dunn
 
.Net Garbage Collector 101
.Net Garbage Collector 101.Net Garbage Collector 101
.Net Garbage Collector 101Woody Pewitt
 
The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)Vyacheslav Lapin
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simplerAlexander Mostovenko
 
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...GeeksLab Odessa
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio
 
Kotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutinesKotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutinesFranco Lombardo
 
Presentation: Everything you wanted to know about writing async, high-concurr...
Presentation: Everything you wanted to know about writing async, high-concurr...Presentation: Everything you wanted to know about writing async, high-concurr...
Presentation: Everything you wanted to know about writing async, high-concurr...Baruch Sadogursky
 
Highlights of F# lightning talk
Highlights of F# lightning talkHighlights of F# lightning talk
Highlights of F# lightning talkmbhwork
 
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer DriverBuilding a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer Driverseleniumconf
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Emery Berger
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and pythonChetan Giridhar
 

Similar to Surviving in an Async-First Development World (20)

Node intro
Node introNode intro
Node intro
 
200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience
 
Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
 
Workers
WorkersWorkers
Workers
 
.Net Garbage Collector 101
.Net Garbage Collector 101.Net Garbage Collector 101
.Net Garbage Collector 101
 
Rxjs kyivjs 2015
Rxjs kyivjs 2015Rxjs kyivjs 2015
Rxjs kyivjs 2015
 
The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
 
Async Programming in C# 5
Async Programming in C# 5Async Programming in C# 5
Async Programming in C# 5
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0
 
Kotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutinesKotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutines
 
Presentation: Everything you wanted to know about writing async, high-concurr...
Presentation: Everything you wanted to know about writing async, high-concurr...Presentation: Everything you wanted to know about writing async, high-concurr...
Presentation: Everything you wanted to know about writing async, high-concurr...
 
Highlights of F# lightning talk
Highlights of F# lightning talkHighlights of F# lightning talk
Highlights of F# lightning talk
 
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer DriverBuilding a Driver: Lessons Learned From Developing the Internet Explorer Driver
Building a Driver: Lessons Learned From Developing the Internet Explorer Driver
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
 
Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and python
 

More from Mirco Vanini

.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdfMirco Vanini
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Mirco Vanini
 
Connect a chips to Azure
Connect a chips to AzureConnect a chips to Azure
Connect a chips to AzureMirco Vanini
 
Connect a chips to Azure
Connect a chips to AzureConnect a chips to Azure
Connect a chips to AzureMirco Vanini
 
How to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKHow to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKMirco Vanini
 
.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop DevelopmentMirco Vanini
 
Async Debugging A Practical Guide to survive !
Async Debugging A Practical Guide to survive !Async Debugging A Practical Guide to survive !
Async Debugging A Practical Guide to survive !Mirco Vanini
 
IoT support for .NET (Core/5/6)
IoT support for .NET (Core/5/6)IoT support for .NET (Core/5/6)
IoT support for .NET (Core/5/6)Mirco Vanini
 
Async Debugging - A Practical Guide to survive !
Async Debugging - A Practical Guide to survive !Async Debugging - A Practical Guide to survive !
Async Debugging - A Practical Guide to survive !Mirco Vanini
 
IoT support for .NET Core
IoT support for .NET CoreIoT support for .NET Core
IoT support for .NET CoreMirco Vanini
 
IoT support for .NET Core - IoT Saturday 2020
IoT support for .NET Core - IoT Saturday 2020IoT support for .NET Core - IoT Saturday 2020
IoT support for .NET Core - IoT Saturday 2020Mirco Vanini
 
.NET Conf 2020 - Hot Topics Desktop Development
.NET Conf 2020 - Hot Topics Desktop Development.NET Conf 2020 - Hot Topics Desktop Development
.NET Conf 2020 - Hot Topics Desktop DevelopmentMirco Vanini
 
Are you ready for Microsoft Azure Sphere?
Are you ready for Microsoft Azure Sphere?Are you ready for Microsoft Azure Sphere?
Are you ready for Microsoft Azure Sphere?Mirco Vanini
 
IoT Day 2019 Naples - Microsoft Azure Shpere
IoT Day 2019 Naples - Microsoft Azure ShpereIoT Day 2019 Naples - Microsoft Azure Shpere
IoT Day 2019 Naples - Microsoft Azure ShpereMirco Vanini
 
Debugging with VS2019
Debugging with VS2019Debugging with VS2019
Debugging with VS2019Mirco Vanini
 
Optimising code using Span<T>
Optimising code using Span<T>Optimising code using Span<T>
Optimising code using Span<T>Mirco Vanini
 
Xe OneDay - Modernizing Enterprise Apps
Xe OneDay - Modernizing Enterprise AppsXe OneDay - Modernizing Enterprise Apps
Xe OneDay - Modernizing Enterprise AppsMirco Vanini
 

More from Mirco Vanini (20)

.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)
 
Connect a chips to Azure
Connect a chips to AzureConnect a chips to Azure
Connect a chips to Azure
 
Connect a chips to Azure
Connect a chips to AzureConnect a chips to Azure
Connect a chips to Azure
 
How to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDKHow to modernise WPF and Windows Forms applications with Windows Apps SDK
How to modernise WPF and Windows Forms applications with Windows Apps SDK
 
C# on a CHIPs
C# on a CHIPsC# on a CHIPs
C# on a CHIPs
 
.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development.NET Conf 2021 - Hot Topics Desktop Development
.NET Conf 2021 - Hot Topics Desktop Development
 
Async Debugging A Practical Guide to survive !
Async Debugging A Practical Guide to survive !Async Debugging A Practical Guide to survive !
Async Debugging A Practical Guide to survive !
 
IoT support for .NET (Core/5/6)
IoT support for .NET (Core/5/6)IoT support for .NET (Core/5/6)
IoT support for .NET (Core/5/6)
 
Async Debugging - A Practical Guide to survive !
Async Debugging - A Practical Guide to survive !Async Debugging - A Practical Guide to survive !
Async Debugging - A Practical Guide to survive !
 
IoT support for .NET Core
IoT support for .NET CoreIoT support for .NET Core
IoT support for .NET Core
 
IoT support for .NET Core - IoT Saturday 2020
IoT support for .NET Core - IoT Saturday 2020IoT support for .NET Core - IoT Saturday 2020
IoT support for .NET Core - IoT Saturday 2020
 
.NET Conf 2020 - Hot Topics Desktop Development
.NET Conf 2020 - Hot Topics Desktop Development.NET Conf 2020 - Hot Topics Desktop Development
.NET Conf 2020 - Hot Topics Desktop Development
 
Are you ready for Microsoft Azure Sphere?
Are you ready for Microsoft Azure Sphere?Are you ready for Microsoft Azure Sphere?
Are you ready for Microsoft Azure Sphere?
 
IoT Day 2019 Naples - Microsoft Azure Shpere
IoT Day 2019 Naples - Microsoft Azure ShpereIoT Day 2019 Naples - Microsoft Azure Shpere
IoT Day 2019 Naples - Microsoft Azure Shpere
 
Debugging with VS2019
Debugging with VS2019Debugging with VS2019
Debugging with VS2019
 
Azure Sphere
Azure SphereAzure Sphere
Azure Sphere
 
Optimising code using Span<T>
Optimising code using Span<T>Optimising code using Span<T>
Optimising code using Span<T>
 
Azure Sphere
Azure SphereAzure Sphere
Azure Sphere
 
Xe OneDay - Modernizing Enterprise Apps
Xe OneDay - Modernizing Enterprise AppsXe OneDay - Modernizing Enterprise Apps
Xe OneDay - Modernizing Enterprise Apps
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Surviving in an Async-First Development World

  • 1. www.xedotnet.org Surviving in an Async-First Development World Mirco Vanini
 Microsoft® MVP Windows Development AllSeen Alliance - AllJoyn® Ambassador OCF® Members
  • 2. Genesis Keywords Costs of Async and Await Understanding the Keywords Context Benefit of Asynchrony Avoid async void Threadpool Configure context 24/03/17 2 Agenda
  • 7. 24/03/17 4 Introducing the Keywords public async Task DoSomethingAsync() { // In the Real World, we would actually do something... // For this example, we're just going to (asynchronously) // wait 100ms. // await Task.Delay(100); } The async and await keywords in C# are the heart of async programming. By using those two keywords, you can use resources in the .NET Framework or the Windows Runtime to create an asynchronous method almost as easily as you create a synchronous method. Asynchronous methods that you define by using  async  and  await  are referred to as async methods.
  • 8. 24/03/17 5 What Happens in an Async Method
  • 9. 24/03/17 6 Question: How it works? Task delayTask = Task.Delay(TimeSpan.FromSecond(2)); 
 var httpClient = new HttpClient(); Task<string> downlaodTask = httpClient.GetStringAsync(htt p://www.example.com);
  • 10. 24/03/17 7 Understanding the Costs of Async and Await public static async Task SimpleBodyAsync()  { Console.WriteLine("Hello, Async World!"); }
  • 11. 24/03/17 7 Understanding the Costs of Async and Await public static async Task SimpleBodyAsync()  { Console.WriteLine("Hello, Async World!"); } [DebuggerStepThrough]      public static Task SimpleBodyAsync() {   <SimpleBodyAsync>d__0 d__ = new <SimpleBodyAsync>d__0 ();   d__.<>t__builder = AsyncTaskMethodBuilder.Create();   d__.MoveNext();   return d__.<>t__builder.Task; }   [CompilerGenerated] [StructLayout(LayoutKind.Sequential)] private struct <SimpleBodyAsync>d__0 : <>t__IStateMachi ne {   private int <>1__state;   public AsyncTaskMethodBuilder <>t__builder;   public Action <>t__MoveNextDelegate;     public void MoveNext() {     try {       if (this.<>1__state == -1) return;       Console.WriteLine("Hello, Async World!");     }     catch (Exception e) {       this.<>1__state = -1;       this.<>t__builder.SetException(e);       return;     }       this.<>1__state = -1;     this.<>t__builder.SetResult();   }     ... }
  • 12. 24/03/17 8 Understanding the Keywords • The “async” keyword enables the “await” keyword in that method and changes how method results are handled. That’s all the async keyword does! It does not run this method on a thread pool thread, or do any other kind of magic. The async keyword  only  enables the await keyword (and manages the method results). • The “await” keyword is where things can get asynchronous. Await is like a unary operator: it takes a single argument, an  awaitable  (an “awaitable” is an asynchronous operation). Await examines that awaitable to see if it has already completed; if the awaitable has already completed, then the method just continues running (synchronously, just like a regular method).
  • 13. 24/03/17 9 Context • When you await a built-in awaitable, then the awaitable will capture the current “context” and later apply it to the remainder of the async method • If you’re on a UI thread, then it’s a UI context. • If you’re responding to an ASP.NET request, then it’s an ASP.NET request context. • Otherwise, it’s usually a thread pool context.
  • 14. 24/03/17 10 Benefit of Asynchrony • Free up threads • This is the opposite of "creating more threads " or "using a thread pool thread "
  • 15. 24/03/17 11 Avoid Async Void • There are three possible return types for async methods: Task, Task<T> and void. • Void-returning async methods have a specific purpose: to make asynchronous event handlers possible • When converting from synchronous to asynchronous code, any method returning a type T becomes an async method returning Task<T>, and any method returning void becomes an async method returning Task
  • 17. 24/03/17 13 Avoid Async Void • Async void is a “fire-and-forget” mechanism... • The caller is unable to know when an async void has finished • The caller is unable to catch exceptions thrown from an async void • Use async void methods only for top-level event handlers (and their like) • Use async Task-returning methods everywhere else If you need fire-and-forget elsewhere, indicate it explicitly e.g. “FredAsync().FireAndForget()”
  • 18. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } Avoid Async Void
  • 19. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } class LayoutAwarePage : Page { private string _pageKey; protected override void OnNavigatedTo(NavigationEventArgs e) { if (this._pageKey != null) return; this._pageKey = "Page-" + this.Frame.BackStackDepth; ... this.LoadState(e.Parameter, null); } } Avoid Async Void
  • 20. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } Avoid Async Void
  • 21. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } Avoid Async Void
  • 22. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } Avoid Async Void
  • 23. 24/03/17 14 // Q. It sometimes shows PixelWidth and PixelHeight are both 0 ??? BitmapImage m_bmp; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); image1.Source = m_bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - m_bmp.PixelWidth); } protected override async void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmp = new BitmapImage(); var file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:/// pic.png"); using (var stream = await file.OpenReadAsync()) { await m_bmp.SetSourceAsync(stream); } } Avoid Async Void
  • 24. 24/03/17 15 Avoid Async Void // A. Use a task Task<BitmapImage> m_bmpTask; protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await PlayIntroSoundAsync(); var bmp = await m_bmpTask; image1.Source = bmp; Canvas.SetLeft(image1, Window.Current.Bounds.Width - bmp.PixelWidth); } protected override void LoadState(Object nav, Dictionary<String, Object> pageState) { m_bmpTask = LoadBitmapAsync(); } private async Task<BitmapImage> LoadBitmapAsync() { var bmp = new BitmapImage(); ... return bmp; }
  • 25. 24/03/17 16 Threadpool // table1.DataSource = LoadHousesSequentially(1,5); // table1.DataBind(); public List<House> LoadHousesSequentially(int first, int last) { var loadedHouses = new List<House>(); for (int i = first; i <= last; i++) { House house = House.Deserialize(i); loadedHouses.Add(house); } return loadedHouses; }
  • 26. 24/03/17 16 Threadpool work1 request in response out
 500ms work2 work3 work4 work5
  • 27. 24/03/17 17 Threadpool // table1.DataSource = LoadHousesInParallel(1,5); // table1.DataBind(); public List<House> LoadHousesInParallel(int first, int last) { var loadedHouses = new BlockingCollection<House>(); Parallel.For(first, last+1, i => { House house = House.Deserialize(i); loadedHouses.Add(house); }); return loadedHouses.ToList(); }
  • 29. 24/03/17 17 Threadpool response out
 300ms work1 work2 work3 work4 work5 Parallel.Forrequest in
  • 30. 24/03/17 17 Threadpool response out
 300ms work1 work2 work3 work4 work5 Parallel.Forrequest in Is it CPU- bound,
 or I/O-bound?
  • 31. 24/03/17 17 Threadpool response out
 300ms work1 work2 work3 work4 work5 Parallel.Forrequest in
  • 32. 24/03/17 18 Threadpool // table1.DataSource = await LoadHousesAsync(1,5); // table1.DataBind(); public async Task<List<House>> LoadHousesAsync(int first, int last) { var tasks = new List<Task<House>>(); for (int i = first; i <= last; i++) { Task<House> t = House.LoadFromDatabaseAsync(i); tasks.Add(t); } House[] loadedHouses = await Task.WhenAll(tasks); return loadedHouses.ToList(); }
  • 35. 24/03/17 19 Threadpool • CPU-bound work means things like: LINQ-over- objects, or big iterations, or computational inner loops. • Parallel.ForEach and Task.Run are a good way to put CPU-bound work onto the thread pool. • Use of threads will never increase throughput on a machine that’s under load. • For IO-bound “work”, use await rather than background threads. • For CPU-bound work, consider using background threads via Parallel.ForEach or Task.Run, unless you're writing a library, or scalable server-side code.
  • 36. 24/03/17 20 Reactive Multithreaded Asynchronous Parallel Concurrent Concurrent mode
  • 37. 24/03/17 21 Configure Context • The “context” is captured by default when an incomplete Task is awaited, and that this captured context is used to resume the async method • Most of the time, you don’t need to sync back to the “main” context ! Most async methods will be designed with composition in mind. • Awaiter not capture the current context by calling ConfigureAwait • Avoids unnecessary thread marshaling • Code shouldn’t block UI thread, but avoids deadlocks if it does
  • 38. 24/03/17 21 Configure Context • The “context” is captured by default when an incomplete Task is awaited, and that this captured context is used to resume the async method • Most of the time, you don’t need to sync back to the “main” context ! Most async methods will be designed with composition in mind. • Awaiter not capture the current context by calling ConfigureAwait • Avoids unnecessary thread marshaling • Code shouldn’t block UI thread, but avoids deadlocks if it does private async void DownloadFileButton_Click(object sender, EventArgs e) { // Since we asynchronously wait, the UI thread is not blocked by the file download. // await DownloadFileAsync(fileNameTextBox.Text); // Since we resume on the UI context, we can directly access UI elements. // resultTextBox.Text = "File downloaded!"; } private async Task DownloadFileAsync(string fileName) { // Use HttpClient or whatever to download the file contents. // var fileContents = await DownloadFileContentsAsync(fileName).ConfigureAwait(false); // Note that because of the ConfigureAwait(false), we are not on the // original context here. // Instead, we're running on the thread pool. // Write the file contents out to a disk file. // await WriteToDiskAsync(fileName, fileContents).ConfigureAwait(false); // The second call to ConfigureAwait(false) is not *required*, but it is Good Practice.
  • 39. 24/03/17 22 Async Console • Unfortunately, that doesn’t work, the compiler will reject an async Main method • You can work around this by providing your own async-compatible contex class Program {   static async void Main(string[] args)   {     ...   } }
  • 40. 24/03/17 22 Async Console • Unfortunately, that doesn’t work, the compiler will reject an async Main method • You can work around this by providing your own async-compatible contex class Program {   static async void Main(string[] args)   {     ...   } } class Program { static int Main(string[] args) { try { return AsyncContext.Run(() => MainAsync(args)); } catch (Exception ex) { Console.Error.WriteLine(ex); return -1; } } static async Task<int> MainAsync(string[] args) {} } Console applications and Win32 services do not have a suitable context, and AsyncContext or AsyncContextThread could be used in those situations.
  • 41. 24/03/17 23 Links • Async and Await • Async/Await - Best Practices in Asynchronous Programming • Async Performance: Understanding the Costs of Async and Await • Async programming deep dive
  • 42. 24/03/17 24 Who I am 
 www.adamfactory.com mirco.vanini@adamfactory.com @MircoVanini Mirco Vanini Microsoft® MVP Windows Development AllSeen Alliance - AllJoyn® Ambassador OCF® Member TinyCLR.it