SlideShare une entreprise Scribd logo
1  sur  30
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
Correcting common mistakes, async await
Correcting common mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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 mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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://www.codetraveler.io/DevFestWeekend-AsyncAwait/
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 mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
Correcting common mistakes, async await
Correcting common mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
@TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/

Contenu connexe

Plus de Brandon Minnick, MBA

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#.pptxBrandon Minnick, MBA
 
Correcting Common .NET Mistakes in Async Await .pptx
Correcting Common .NET Mistakes in Async Await .pptxCorrecting Common .NET Mistakes in Async Await .pptx
Correcting Common .NET Mistakes in Async Await .pptxBrandon Minnick, MBA
 
Introducing .NET MAUI Toolkit.pptx
Introducing .NET MAUI Toolkit.pptxIntroducing .NET MAUI Toolkit.pptx
Introducing .NET MAUI Toolkit.pptxBrandon Minnick, MBA
 
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 + WindowsBrandon Minnick, MBA
 
Creating iOS & Android Apps using Xamarin
Creating iOS & Android Apps using XamarinCreating iOS & Android Apps using Xamarin
Creating iOS & Android Apps using XamarinBrandon Minnick, MBA
 
Creating Native iOS & Android Apps in C#
Creating Native iOS & Android Apps in C#Creating Native iOS & Android Apps in C#
Creating Native iOS & Android Apps in C#Brandon Minnick, MBA
 
DevReach: Creating Xamarin.Forms UIs in C#
DevReach: Creating Xamarin.Forms UIs in C#DevReach: Creating Xamarin.Forms UIs in C#
DevReach: Creating Xamarin.Forms UIs in C#Brandon Minnick, MBA
 
Creating Serverless Apps without Writing Any Code
Creating Serverless Apps without Writing Any CodeCreating Serverless Apps without Writing Any Code
Creating Serverless Apps without Writing Any CodeBrandon Minnick, MBA
 

Plus de Brandon Minnick, MBA (20)

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
 
Correcting Common .NET Mistakes in Async Await .pptx
Correcting Common .NET Mistakes in Async Await .pptxCorrecting Common .NET Mistakes in Async Await .pptx
Correcting Common .NET Mistakes in Async Await .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
 
Xamarin + GraphQL
Xamarin + GraphQLXamarin + GraphQL
Xamarin + GraphQL
 
Creating Native iOS & Android Apps in C#
Creating Native iOS & Android Apps in C#Creating Native iOS & Android Apps in C#
Creating Native iOS & Android Apps in C#
 
DevReach: Creating Xamarin.Forms UIs in C#
DevReach: Creating Xamarin.Forms UIs in C#DevReach: Creating Xamarin.Forms UIs in C#
DevReach: Creating Xamarin.Forms UIs in C#
 
The Future of Xamarin
The Future of XamarinThe Future of Xamarin
The Future of Xamarin
 
Creating Serverless Apps without Writing Any Code
Creating Serverless Apps without Writing Any CodeCreating Serverless Apps without Writing Any Code
Creating Serverless Apps without Writing Any Code
 
The Future of Xamarin
The Future of XamarinThe Future of Xamarin
The Future of Xamarin
 

Dernier

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Dernier (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Correcting common mistakes, async await

Notes de l'éditeur

  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
  4. Best way to learn – free videos Paid for instructors Certification, actually valued by employers Great ecosystem of books