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

Weitere ähnliche Inhalte

Andere mochten auch (16)

Sun
SunSun
Sun
 
Bài 5
Bài 5Bài 5
Bài 5
 
Jeff king iditarod 2014
Jeff king iditarod 2014Jeff king iditarod 2014
Jeff king iditarod 2014
 
Pols presentation
Pols presentation Pols presentation
Pols presentation
 
Croazia turismo
Croazia turismoCroazia turismo
Croazia turismo
 
rahul recent
rahul recentrahul recent
rahul recent
 
Grading visible learners nagel-slides visible learning institute san diego
Grading visible learners nagel-slides visible learning institute san diegoGrading visible learners nagel-slides visible learning institute san diego
Grading visible learners nagel-slides visible learning institute san diego
 
Competition presentation
Competition presentationCompetition presentation
Competition presentation
 
English project
English projectEnglish project
English project
 
Trabajo marta y ana (inglés)
Trabajo marta y ana (inglés)Trabajo marta y ana (inglés)
Trabajo marta y ana (inglés)
 
My food diary Marco 5a
My food diary Marco 5aMy food diary Marco 5a
My food diary Marco 5a
 
Tarea 1. corrección
Tarea 1. correcciónTarea 1. corrección
Tarea 1. corrección
 
My favorite sports alejandro 5b si blog
My favorite sports alejandro 5b si blogMy favorite sports alejandro 5b si blog
My favorite sports alejandro 5b si blog
 
Toscana turismo
Toscana turismoToscana turismo
Toscana turismo
 
創業管理:兼職創業者完整課程 week7
創業管理:兼職創業者完整課程 week7創業管理:兼職創業者完整課程 week7
創業管理:兼職創業者完整課程 week7
 
創業管理:兼職創業者完整課程 Week 5
創業管理:兼職創業者完整課程 Week 5創業管理:兼職創業者完整課程 Week 5
創業管理:兼職創業者完整課程 Week 5
 

Ähnlich wie Async ASP.NET Applications

Async and Await on the Server
Async and Await on the ServerAsync and Await on the Server
Async and Await on the ServerDoug Jones
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Rainer Stropek
 
Async in .NET
Async in .NETAsync in .NET
Async in .NETRTigger
 
Webcast: Asynchronous Programming Demystified
Webcast: Asynchronous Programming DemystifiedWebcast: Asynchronous Programming Demystified
Webcast: Asynchronous Programming DemystifiedSerge Baranovsky
 
End to-end async and await
End to-end async and awaitEnd to-end async and await
End to-end async and awaitvfabro
 
Task parallel library presentation
Task parallel library presentationTask parallel library presentation
Task parallel library presentationahmed sayed
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio
 
Liberating web apps from the server
Liberating web apps from the serverLiberating web apps from the server
Liberating web apps from the serverAlexander Gyoshev
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextPrateek Maheshwari
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!Jeff Anderson
 
ApacheCon NA 2010 - Building Apps with Apache Tuscany
ApacheCon NA 2010 - Building Apps with Apache TuscanyApacheCon NA 2010 - Building Apps with Apache Tuscany
ApacheCon NA 2010 - Building Apps with Apache TuscanyJean-Sebastien Delfino
 
Asynchronous Programming.pptx
Asynchronous Programming.pptxAsynchronous Programming.pptx
Asynchronous Programming.pptxAayush Chimaniya
 
.Net Multithreading and Parallelization
.Net Multithreading and Parallelization.Net Multithreading and Parallelization
.Net Multithreading and ParallelizationDmitri Nesteruk
 
Ddd melbourne 2011 C# async ctp
Ddd melbourne 2011  C# async ctpDdd melbourne 2011  C# async ctp
Ddd melbourne 2011 C# async ctpPratik Khasnabis
 

Ähnlich wie Async ASP.NET Applications (20)

Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
Async and Await on the Server
Async and Await on the ServerAsync and Await on the Server
Async and Await on the Server
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
 
Async in .NET
Async in .NETAsync in .NET
Async in .NET
 
Webcast: Asynchronous Programming Demystified
Webcast: Asynchronous Programming DemystifiedWebcast: Asynchronous Programming Demystified
Webcast: Asynchronous Programming Demystified
 
End to-end async and await
End to-end async and awaitEnd to-end async and await
End to-end async and await
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 
Async Programming in C# 5
Async Programming in C# 5Async Programming in C# 5
Async Programming in C# 5
 
Task parallel library presentation
Task parallel library presentationTask parallel library presentation
Task parallel library presentation
 
Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0Binary Studio Academy: Concurrency in C# 5.0
Binary Studio Academy: Concurrency in C# 5.0
 
Spring Actionscript at Devoxx
Spring Actionscript at DevoxxSpring Actionscript at Devoxx
Spring Actionscript at Devoxx
 
Liberating web apps from the server
Liberating web apps from the serverLiberating web apps from the server
Liberating web apps from the server
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 
Concurrecny inf sharp
Concurrecny inf sharpConcurrecny inf sharp
Concurrecny inf sharp
 
ApacheCon NA 2010 - Building Apps with Apache Tuscany
ApacheCon NA 2010 - Building Apps with Apache TuscanyApacheCon NA 2010 - Building Apps with Apache Tuscany
ApacheCon NA 2010 - Building Apps with Apache Tuscany
 
Asynchronous Programming.pptx
Asynchronous Programming.pptxAsynchronous Programming.pptx
Asynchronous Programming.pptx
 
.Net Multithreading and Parallelization
.Net Multithreading and Parallelization.Net Multithreading and Parallelization
.Net Multithreading and Parallelization
 
Ddd melbourne 2011 C# async ctp
Ddd melbourne 2011  C# async ctpDdd melbourne 2011  C# async ctp
Ddd melbourne 2011 C# async ctp
 

Kürzlich hochgeladen

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 

Kürzlich hochgeladen (20)

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 

Async 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
  • 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
  • 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 
  • 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!