Top Banner
Async best-practices Welcome webinar
27

Async/Await Best Practices

Jan 24, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Async/Await Best Practices

Async best-practicesWelcome

webinar

Page 2: Async/Await Best Practices

Solution Architect

Enthusiastic Software Engineer

Microsoft MVP for systems integration

@danielmarbach

particular.net/blog

planetgeek.ch

Page 3: Async/Await Best Practices

GoalsCPU-bound vs IO-bound

Threads and Tasks

Async best-practices

target

Page 4: Async/Await Best Practices

Terminology Code WrapUp

Page 6: Async/Await Best Practices

Terminology Code WrapUp

Page 7: Async/Await Best Practices

event-driven

async

Page 8: Async/Await Best Practices

Taskuniform

Page 9: Async/Await Best Practices

TaskIO-bound

Page 10: Async/Await Best Practices

TaskCPU-bound

Page 11: Async/Await Best Practices

concurrentinterleaved

Page 12: Async/Await Best Practices

parallelsimultaneous

Page 13: Async/Await Best Practices

Continuationfunction

Page 14: Async/Await Best Practices

Terminology Code WrapUp

Page 15: Async/Await Best Practices

async/awaitsimplicity

function1(function(err, res) {

function2(function(err, res) {

function3(function(err, res) {

function4(function(err, res) {

function5(function(err, res) {

// do something useful

})

})

})

})})

Page 16: Async/Await Best Practices

cleanLaundry.ContinueWith(t => {

dryLaundry;})

Page 17: Async/Await Best Practices

await cleanLaundry;dryLaundry;

Page 18: Async/Await Best Practices

Demoawait

Page 19: Async/Await Best Practices

Terminology Code WrapUp

Page 20: Async/Await Best Practices

Forget thread!

think

Page 21: Async/Await Best Practices

NSB v6Will be Async all the way

Applies the shown best-practies like

ConfigureAwait(false) consequently,

checked with Roslyn analyzer

particular.net/blog/async-await-its-time

Page 22: Async/Await Best Practices

RecapUse Task.Run, Factory.StartNew for

CPU-bound work

Use Task directly for IO-bound work

Use async Task instead of async voidreminder

Page 23: Async/Await Best Practices

RecapLibraries and frameworks should use

ConfigureAwait(false)

Async all the way, don’t mix blocking and asynchronous code

reminder

Page 24: Async/Await Best Practices

Next

particular.net/async-await-webinar-series

Page 25: Async/Await Best Practices

github.com/danielmarbach/02-25-2016-AsyncWebinar

Slides, Links…

Page 26: Async/Await Best Practices

Q & Aawait

Page 27: Async/Await Best Practices

Thanks