Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

Download to read offline

Correcting common mistakes, async await

Download to read offline

Correcting common mistakes, async await

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Correcting common mistakes, async await

  1. 1. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  2. 2. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  3. 3. @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); }
  4. 4. @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
  5. 5. @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
  6. 6. @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
  7. 7. @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); }
  8. 8. @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
  9. 9. @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;
  10. 10. @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();
  11. 11. @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(); }
  12. 12. @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;
  13. 13. @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;
  14. 14. @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) { . . . }
  15. 15. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  16. 16. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  17. 17. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  18. 18. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  19. 19. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  20. 20. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  21. 21. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  22. 22. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  23. 23. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/
  24. 24. @TheCodeTraveler https://www.codetraveler.io/DevFestWeekend-AsyncAwait/

Correcting common mistakes, async await

Views

Total views

94

On Slideshare

0

From embeds

0

Number of embeds

0

Actions

Downloads

3

Shares

0

Comments

0

Likes

0

×