SlideShare a Scribd company logo
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
Thread 1
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
Thread 2*
*Can be any thread other than Thread 1
e.g. Thread 32
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
Thread 1
Correcting Common .NET Mistakes in Async Await .pptx
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
private sealed class <ReadDataFromUrl>d_1 : IAsyncStateMachine
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
private string <data>5_3;
private byte[] <result>5_2;
private WebClient <wc>5_1;
public string url;
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
async Task ReadDataFromUrl(string url)
{
WebClient wc = new WebClient();
byte[] result = await wc.DownloadDataTaskAsync(url);
string data = Encoding.ASCII.GetString(result);
LoadData(data);
}
private void MoveNext();
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
public void MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
try {
switch (num) {
case 0:
this.<wc>__0 = new WebClient();
this.$awaiter0 = this.<wc>__0.DownloadDataTaskAsync(this.url).GetAwaiter();
this.$PC = 1;
...
return;
break;
case 1:
this.<result>__1 = this.$awaiter0.GetResult();
this.<data>__2 = Encoding.ASCII.GetString(this.<result>__1);
this.$this.LoadData(this.<data>__2);
break;
default:
return;
}
}
catch (Exception exception) { ... }
this.$PC = -1;
this.$builder.SetResult();
}
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
public void MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
try {
switch (num) {
case 0:
this.<wc>__0 = new WebClient();
this.$awaiter0 = this.<wc>__0.DownloadDataTaskAsync(this.url).GetAwaiter();
this.$PC = 1;
...
return;
break;
case 1:
this.<result>__1 = this.$awaiter0.GetResult();
this.<data>__2 = Encoding.ASCII.GetString(this.<result>__1);
this.$this.LoadData(this.<data>__2);
break;
default:
return;
}
}
catch (Exception exception) { ... }
this.$PC = -1;
this.$builder.SetResult();
}
case 0:
this.<wc>__0 = new WebClient();
this.$awaiter0 = this.<wc>__0.DownloadDataTaskAsync(this.url).GetAwaiter();
this.$PC = 1;
...
return;
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
public void MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
try {
switch (num) {
case 0:
this.<wc>__0 = new WebClient();
this.$awaiter0 = this.<wc>__0.DownloadDataTaskAsync(this.url).GetAwaiter();
this.$PC = 1;
...
return;
break;
case 1:
this.<result>__1 = this.$awaiter0.GetResult();
this.<data>__2 = Encoding.ASCII.GetString(this.<result>__1);
this.$this.LoadData(this.<data>__2);
break;
default:
return;
}
}
catch (Exception exception) { ... }
this.$PC = -1;
this.$builder.SetResult();
}
case 1:
this.<result>__1 = this.$awaiter0.GetResult();
this.<data>__2 = Encoding.ASCII.GetString(this.<result>__1);
this.$this.LoadData(this.<data>__2);
break;
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
public void MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
try {
switch (num) {
case 0:
this.<wc>__0 = new WebClient();
this.$awaiter0 = this.<wc>__0.DownloadDataTaskAsync(this.url).GetAwaiter();
this.$PC = 1;
...
return;
break;
case 1:
this.<result>__1 = this.$awaiter0.GetResult();
this.<data>__2 = Encoding.ASCII.GetString(this.<result>__1);
this.$this.LoadData(this.<data>__2);
break;
default:
return;
}
}
catch (Exception exception) { ... }
this.$PC = -1;
this.$builder.SetResult();
}
try {
catch (Exception exception) { . . . }
Correcting Common .NET Mistakes in Async Await .pptx
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
Correcting Common .NET Mistakes in Async Await .pptx
Correcting Common .NET Mistakes in Async Await .pptx
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
https://codetraveler.io/kcdc-async-await/
@TheCodeTraveler https://codetraveler.io/kcdc-async-await/
https://codetraveler.io/kcdc-async-await/

More Related Content

PPTX
Correcting Common Async/Await Mistakes in .NET
PPTX
Correcting Common .NET Async/Await Mistakes
PPTX
Correcting Common Async Await Mistakes in .NET
PDF
Non Blocking I/O for Everyone with RxJava
PDF
Asynchronní programování
PPTX
分散式系統
PPT
Async programming on NET
PPTX
Managing State in React Apps with RxJS by James Wright at FrontCon 2019
Correcting Common Async/Await Mistakes in .NET
Correcting Common .NET Async/Await Mistakes
Correcting Common Async Await Mistakes in .NET
Non Blocking I/O for Everyone with RxJava
Asynchronní programování
分散式系統
Async programming on NET
Managing State in React Apps with RxJS by James Wright at FrontCon 2019

Similar to Correcting Common .NET Mistakes in Async Await .pptx (20)

PPT
Expert JavaScript tricks of the masters
PDF
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
PDF
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
PPTX
C#을 이용한 task 병렬화와 비동기 패턴
PPTX
13 networking, mobile services, and authentication
PDF
XQuery Rocks
PPTX
Bare-knuckle web development
PDF
Tomcat连接池配置方法V2.1
PPTX
Reactive programming every day
PDF
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
PDF
Arduino and the real time web
PPTX
Async Best Practices
PDF
Speed up your Web applications with HTML5 WebSockets
PDF
Qt Network Explained (Portuguese)
PDF
Reactive programming on Android
PDF
Concept of BlockChain & Decentralized Application
PDF
Node.js server-side rendering
DOCX
assigemt calculater.docx
PDF
Server Side Swift: Vapor
PPT
JDBC for CSQL Database
Expert JavaScript tricks of the masters
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
GDG Jakarta Meetup - Streaming Analytics With Apache Beam
C#을 이용한 task 병렬화와 비동기 패턴
13 networking, mobile services, and authentication
XQuery Rocks
Bare-knuckle web development
Tomcat连接池配置方法V2.1
Reactive programming every day
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
Arduino and the real time web
Async Best Practices
Speed up your Web applications with HTML5 WebSockets
Qt Network Explained (Portuguese)
Reactive programming on Android
Concept of BlockChain & Decentralized Application
Node.js server-side rendering
assigemt calculater.docx
Server Side Swift: Vapor
JDBC for CSQL Database
Ad

More from Brandon Minnick, MBA (20)

PPTX
Choosing The Best AWS Service For Your Website + API.pptx
PPTX
Introduction to Serverless with AWS Lambda in C#.pptx
PPTX
Correcting Common Mistakes, AsyncAwait.pptx
PPTX
The .NET MAUI Community Toolkits.pptx
PPTX
Introduction to Serverless with AWS Lambda in C#.pptx
PPTX
AWS Toolkit.pptx
PPTX
Building GraphQL APIs in C#.pptx
PPTX
Building MAUI UIs in C#.pptx
PPTX
Creating Apps with .NET MAUI.pptx
PPTX
Building GraphQL APIs in C#.pptx
PPTX
Introduction to Serverless with AWS Lambda in C#.pptx
PPTX
Consuming GraphQL APIs in C#.pptx
PPTX
Building GraphQL API in C#.pptx
PPTX
Introducing .NET MAUI Toolkit.pptx
PPTX
Building MAUI UI in C#.pptx
PPTX
Building GraphQL API in C#.pptx
PPTX
Creating Apps with .NET MAUI
PPTX
Creating Apps With .NET MAUI for iOS, Android, macOS + Windows
PPTX
Creating Xamarin.Forms UIs is C#
PPTX
The Future of Xamarin
Choosing The Best AWS Service For Your Website + API.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
Correcting Common Mistakes, AsyncAwait.pptx
The .NET MAUI Community Toolkits.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
AWS Toolkit.pptx
Building GraphQL APIs in C#.pptx
Building MAUI UIs in C#.pptx
Creating Apps with .NET MAUI.pptx
Building GraphQL APIs in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
Consuming GraphQL APIs in C#.pptx
Building GraphQL API in C#.pptx
Introducing .NET MAUI Toolkit.pptx
Building MAUI UI in C#.pptx
Building GraphQL API in C#.pptx
Creating Apps with .NET MAUI
Creating Apps With .NET MAUI for iOS, Android, macOS + Windows
Creating Xamarin.Forms UIs is C#
The Future of Xamarin
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
Teaching material agriculture food technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Digital-Transformation-Roadmap-for-Companies.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
Programs and apps: productivity, graphics, security and other tools
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Assigned Numbers - 2025 - Bluetooth® Document
Teaching material agriculture food technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

Correcting Common .NET Mistakes in Async Await .pptx

Editor's Notes

  • #3: Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes
  • #9: Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes
  • #10: Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes