Download presentation
Presentation is loading. Please wait.
Published byClaud Beasley Modified over 9 years ago
2
WHO WILL BENEFIT FROM THIS TALK TOPICS WHAT YOU’LL LEAVE WITH ASP.NET developers, including Web Forms & MVC History of async programming in.NET How async works in ASP.NET Using async in ASP.NET apps How to use async programming 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
3
A brief history of async programming in.NET
4
Asynchronous Programming Model (APM) Evented Asynchronous Programming (EAP) Task-based Asynchronous Programming (TAP)
5
//.NET 1 model file.BeginRead(buffer, 0, maxLength, asyncResult => { int numBytesRead = file.EndRead(asyncResult); // Now do something with "buffer“ }, null); Asynchronous Programming Model (APM)
6
//.NET 2 model webClient.DownloadStringCompleted += (sender, args) => { string html = args.Result; // Now do something with "html" }; webClient.DownloadStringAsync(new Uri("http://example.com"));
7
Task htmlTask = webClient.DownloadStringTaskAsync(url); htmlTask.ContinueWith(task => { string html = task.Result; // Async, C# 4 }); string html = htmlTask.Result; // Sync (block until done) string html = await htmlTask; // Async, C# 5
8
public async Task MyMethod() { string myParam = "some value"; var data = await FetchSomeData(myParam); return View(data); } 2 1 public Task MyMethod() { string myParam = "some value"; return FetchSomeData(myParam).ContinueWith(task => { var data = task.Result; return View(data); }); } 2 1 Before compilation After compilation (conceptual)
9
How async requests work in ASP.NET
10
Traditional Web request handling “thread-per-request” a.k.a. “post office” Thread pool Requests 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
18
TOOL-810T: Async made simple in Windows 8, with C# and Visual Basic RELATED SESSIONS DOCUMENTATION & ARTICLES http://www.asp.net/vnext
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.