SlideShare una empresa de Scribd logo
1 de 27
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
Correcting common mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-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/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
Correcting common mistakes, async await
Correcting common mistakes, async await
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait
@TheCodeTraveler https://www.codetraveler.io/NDCSydney-2018-AsyncAwait

Más contenido relacionado

Más 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
 

Más 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
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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 WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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 organizationRadu Cotescu
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Correcting common mistakes, async await

Notas del editor

  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