DEVintersection
Session AS12
Building Asynchronous ASP.NET Applications
2
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Agenda
 Quick History
 When is Async Useful
 P...
3
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Async in .NET
.NET Framework 1.0 / 1.1
 1.0 – no...
4
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Async in .NET
.NET Framework 2.0
 EAP: Event-bas...
5
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Async in .NET
.NET Framework 4.0
 TPL: Task Para...
6
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Async in .NET
.NET Framework 4.5
 async/await ke...
7
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
When to Async
When is it most useful?
 I/O


...
8
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Application Architecture
50 States
Web API
Web Fo...
Demo
WebForms
10
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
WebForms
Notes
 DO NOT async your Page_Load
 R...
Demo
MVC / Web API
12
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
MVC / Web API
Notes
 Simple & Transparent
 Mar...
13
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Parallelism
 Task.WhenAll
 Task.Run, ThreadPo...
Demo
Parallelism
15
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Final Comments
 Avoid using Background Threads...
16
© DEVintersection. All rights reserved.
http://www.DEVintersection.com
Resource & Links
 Hanselminutes Podcast – Every...
Questions?
Thank you!
Don’t forget to enter your evaluation
of this session using EventBoard!
Upcoming SlideShare
Loading in...5
×

Async ASP.NET Applications

555

Published on

Learn how to take advantage of the new async/await operations to keep your applications responsive and avoid the performance bottlenecks. In comparison to how async code has been written with callbacks, the new way allows for cleaner more readable debug-able code. In this presentation, topics covered: Web Forms, MVC, EF6 some tooling.

Published in: Software, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
555
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Async ASP.NET Applications

  1. 1. DEVintersection Session AS12 Building Asynchronous ASP.NET Applications
  2. 2. 2 © DEVintersection. All rights reserved. http://www.DEVintersection.com Agenda  Quick History  When is Async Useful  Parallelism  Tips & Resources
  3. 3. 3 © DEVintersection. All rights reserved. http://www.DEVintersection.com Async in .NET .NET Framework 1.0 / 1.1  1.0 – no async available  1.1 – APM: Async Programming Model IAsyncResult result = StartProcess(..); // continue doing other work // checking result.IsCompleted int final = EndProcess(result);
  4. 4. 4 © DEVintersection. All rights reserved. http://www.DEVintersection.com Async in .NET .NET Framework 2.0  EAP: Event-base Async Pattern ProcessCompleted += (sender, e) => { // process the result here }; AsyncProcessStart(…);
  5. 5. 5 © DEVintersection. All rights reserved. http://www.DEVintersection.com Async in .NET .NET Framework 4.0  TPL: Task Parallel Library  Task<int> t = ProcessAsync(…); // process other work // check t.Status, t.IsFaulted, etc. int result = t.Result;
  6. 6. 6 © DEVintersection. All rights reserved. http://www.DEVintersection.com Async in .NET .NET Framework 4.5  async/await keywords public async Task<int> Process() { int result = await CompleteWork(); return result; }
  7. 7. 7 © DEVintersection. All rights reserved. http://www.DEVintersection.com When to Async When is it most useful?  I/O    Parallelism  Long Running Tasks
  8. 8. 8 © DEVintersection. All rights reserved. http://www.DEVintersection.com Application Architecture 50 States Web API Web Forms Application Warnings db
  9. 9. Demo WebForms
  10. 10. 10 © DEVintersection. All rights reserved. http://www.DEVintersection.com WebForms Notes  DO NOT async your Page_Load  RegisterAsyncTask  Set Async=“true” on your .aspx page to enable async pipeline
  11. 11. Demo MVC / Web API
  12. 12. 12 © DEVintersection. All rights reserved. http://www.DEVintersection.com MVC / Web API Notes  Simple & Transparent  Mark method as async, return Task<T>  Use Entity Framework >= 6.1 for async methods  
  13. 13. 13 © DEVintersection. All rights reserved. http://www.DEVintersection.com Parallelism  Task.WhenAll  Task.Run, ThreadPool.QueueUserWorkItem 
  14. 14. Demo Parallelism
  15. 15. 15 © DEVintersection. All rights reserved. http://www.DEVintersection.com Final Comments  Avoid using Background Threads  Do not use Task.Wait()   Avoid Using Task.ContinueWith   Parallel != Async 
  16. 16. 16 © DEVintersection. All rights reserved. http://www.DEVintersection.com Resource & Links  Hanselminutes Podcast – Everything .NET programmers know about Asynchronous Programming is wrong. http://hanselminutes.com/327/everything-net-programmers-know- about-asynchronous-programming-is-wrong  Using Asynchronous Methods in ASP.NET 4.5 http://www.asp.net/web-forms/tutorials/aspnet-45/using-asynchronous- methods-in-aspnet-45  Contact Information 
  17. 17. Questions? Thank you! Don’t forget to enter your evaluation of this session using EventBoard!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×