Your SlideShare is downloading. ×

Async ASP.NET Applications

515

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 …

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
515
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DEVintersection Session AS12 Building Asynchronous ASP.NET Applications
  • 2. 2 © DEVintersection. All rights reserved. http://www.DEVintersection.com Agenda  Quick History  When is Async Useful  Parallelism  Tips & Resources
  • 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 © 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 © 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 © 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 © DEVintersection. All rights reserved. http://www.DEVintersection.com When to Async When is it most useful?  I/O    Parallelism  Long Running Tasks
  • 8. 8 © DEVintersection. All rights reserved. http://www.DEVintersection.com Application Architecture 50 States Web API Web Forms Application Warnings db
  • 9. Demo WebForms
  • 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. Demo MVC / Web API
  • 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 © DEVintersection. All rights reserved. http://www.DEVintersection.com Parallelism  Task.WhenAll  Task.Run, ThreadPool.QueueUserWorkItem 
  • 14. Demo Parallelism
  • 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 © 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. Questions? Thank you! Don’t forget to enter your evaluation of this session using EventBoard!

×