1 / 21

Building IIS and ASP.NET apps with the power of async

SAC-804T. Building IIS and ASP.NET apps with the power of async. Damian Edwards, Phil Haack Program Managers, ASP.NET Microsoft Corporation. Agenda slide. WHO WILL BENEFIT FROM THIS TALK. TOPICS. WHAT YOU’LL LEAVE WITH.

kassidy
Download Presentation

Building IIS and ASP.NET apps with the power of async

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SAC-804T Building IIS and ASP.NET apps with the power of async Damian Edwards, Phil Haack Program Managers, ASP.NET Microsoft Corporation

  2. Agenda slide WHO WILL BENEFIT FROM THIS TALK TOPICS WHAT YOU’LL LEAVE WITH • How to use asyncprogramming in ASP.NET to increase scalability, improve page response time and implement long running requests • The Task Parallel Library (TPL) and async/await support in in C# and .NET 4.5 makes programming async much easier than traditional APM • ASP.NET 4.5, including the core framework, Web Forms and MVC, has great support for working with the TPL and async/await • History of async programming in .NET • How async works in ASP.NET • Using async in ASP.NET apps • ASP.NET developers, including Web Forms & MVC

  3. A brief history of async programming in .NET

  4. Three async programming models Asynchronous Programming Model (APM) Evented Asynchronous Programming (EAP) Task-based Asynchronous Programming (TAP)

  5. Asynchronous Programming Model (APM) Asynchronous Programming Model (APM) // .NET 1 model file.BeginRead(buffer, 0, maxLength, asyncResult => { intnumBytesRead = file.EndRead(asyncResult); // Now do something with "buffer“ }, null);

  6. Event-based Asynchronous Programming (EAP) // .NET 2 model webClient.DownloadStringCompleted += (sender, args) => { string html = args.Result; // Now do something with "html" }; webClient.DownloadStringAsync(newUri("http://example.com"));

  7. Task-based Asynchronous Programming (TAP) Task<string> htmlTask= webClient.DownloadStringTaskAsync(url); string html = htmlTask.Result; // Sync (block until done) htmlTask.ContinueWith(task => { string html = task.Result; // Async, C# 4 }); string html = awaithtmlTask; // Async, C# 5

  8. How C# 5 “async” works publicasyncTask<ViewResult> MyMethod() { stringmyParam = "some value"; var data = awaitFetchSomeData(myParam); return View(data); } Before compilation 1 2 After compilation (conceptual) publicTask<ViewResult> MyMethod() { stringmyParam = "some value"; return FetchSomeData(myParam).ContinueWith(task => { vardata = task.Result; return View(data); }); } 1 2

  9. How async requests work in ASP.NET

  10. Traditional Web request handling “thread-per-request” a.k.a. “post office” Requests Thread pool Busy Busy Busy Busy

  11. Asynchronous Web request handling a.k.a. “restaurant” Requests Thread pool

  12. Using async for benefit in ASP.NET apps. Easy as 1, 3, 2

  13. So can I just use async everywhere in my ASP.NET app? No!

  14. There are three (3) distinct scenarios where async in ASP.NET apps might be useful…

  15. demo Async IO in ASP.NET

  16. demo Parallelizing work for faster request throughput

  17. demo Handling long running, event driven requests

  18. For more information RELATED SESSIONS DOCUMENTATION & ARTICLES http://www.asp.net/vnext TOOL-810T: Async made simple in Windows 8, with C# and Visual Basic

  19. thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback

  20. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related