SlideShare ist ein Scribd-Unternehmen logo
1 von 27
@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
@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) { . . . }
@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/
@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/

Weitere ähnliche Inhalte

Ähnlich wie Correcting Common .NET Mistakes in Async Await .pptx

Ähnlich wie Correcting Common .NET Mistakes in Async Await .pptx (20)

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

Mehr von Brandon Minnick, MBA

Mehr von Brandon Minnick, MBA (20)

Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
 
Correcting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptxCorrecting Common Mistakes, AsyncAwait.pptx
Correcting Common Mistakes, AsyncAwait.pptx
 
The .NET MAUI Community Toolkits.pptx
The .NET MAUI Community Toolkits.pptxThe .NET MAUI Community Toolkits.pptx
The .NET MAUI Community Toolkits.pptx
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
 
AWS Toolkit.pptx
AWS Toolkit.pptxAWS Toolkit.pptx
AWS Toolkit.pptx
 
Building GraphQL APIs in C#.pptx
Building GraphQL APIs in C#.pptxBuilding GraphQL APIs in C#.pptx
Building GraphQL APIs in C#.pptx
 
Building MAUI UIs in C#.pptx
Building MAUI UIs in C#.pptxBuilding MAUI UIs in C#.pptx
Building MAUI UIs in C#.pptx
 
Creating Apps with .NET MAUI.pptx
Creating Apps with .NET MAUI.pptxCreating Apps with .NET MAUI.pptx
Creating Apps with .NET MAUI.pptx
 
Building GraphQL APIs in C#.pptx
Building GraphQL APIs in C#.pptxBuilding GraphQL APIs in C#.pptx
Building GraphQL APIs in C#.pptx
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
 
Consuming GraphQL APIs in C#.pptx
Consuming GraphQL APIs in C#.pptxConsuming GraphQL APIs in C#.pptx
Consuming GraphQL APIs in C#.pptx
 
Building GraphQL API in C#.pptx
Building GraphQL API in C#.pptxBuilding GraphQL API in C#.pptx
Building GraphQL API in C#.pptx
 
Introducing .NET MAUI Toolkit.pptx
Introducing .NET MAUI Toolkit.pptxIntroducing .NET MAUI Toolkit.pptx
Introducing .NET MAUI Toolkit.pptx
 
Building MAUI UI in C#.pptx
Building MAUI UI in C#.pptxBuilding MAUI UI in C#.pptx
Building MAUI UI in C#.pptx
 
Building GraphQL API in C#.pptx
Building GraphQL API in C#.pptxBuilding GraphQL API in C#.pptx
Building GraphQL API in C#.pptx
 
Creating Apps with .NET MAUI
Creating Apps with .NET MAUICreating Apps with .NET MAUI
Creating Apps with .NET MAUI
 
Creating Apps With .NET MAUI for iOS, Android, macOS + Windows
Creating AppsWith .NET MAUIfor iOS, Android, macOS + WindowsCreating AppsWith .NET MAUIfor iOS, Android, macOS + Windows
Creating Apps With .NET MAUI for iOS, Android, macOS + Windows
 
Creating Xamarin.Forms UIs is C#
Creating Xamarin.Forms UIs is C#Creating Xamarin.Forms UIs is C#
Creating Xamarin.Forms UIs is C#
 
The Future of Xamarin
The Future of XamarinThe Future of Xamarin
The Future of Xamarin
 
Creating iOS & Android Apps using Xamarin
Creating iOS & Android Apps using XamarinCreating iOS & Android Apps using Xamarin
Creating iOS & Android Apps using Xamarin
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Correcting Common .NET Mistakes in Async Await .pptx

Hinweis der Redaktion

  1. Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes
  2. Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes
  3. Every time we add the `async` keyword, the compiler creates a new class. Each class increases our app size by appx. 100 bytes