SlideShare a Scribd company logo
Asynchronous
programming in ASP.NET
Name:
Role:
https://nl.linkedin.com/in/alexthissen
@alexthissen
http://blog.alexthissen.nl
Alex Thissen
Lead Consultant, Xpirit
Introducing myself
Agenda
• Introduction on synchronicity
• Threading and async programming in .NET
• Details for
• ASP.NET WebForms
• ASP.NET MVC
• ASP.NET WebAPI
• ASP.NET SignalR
• Gotchas
• Questions and Answers
Talking about
synchronicity
Primer on async and multi-threading in Windows and .NET
(A)Synchronous in a web world
Message
Exchange
Patterns
Parallelization
vs. multi-
threading
High Latency
vs high
throughput
Asynchronicity
is easy now
Blocking
operations
Asynchronous
is faster
A tale of fast food restaurants
Threading in Windows and .NET
• Two concurrency types in Windows Operating
System
1. Worker threads
Physical units of work
2. IO Completion Ports
Special construct for async
I/O bound operations
• Threads incur overhead
• But threads waiting for IO Completion Port are efficient
.NET Threading primitives
• System.Threading namespace
• Threads: Thread and ThreadPool
• Locks: Mutex, WaitHandle, Semaphore, Monitor, Interlocked
• ThreadPool cannot scale hard
(2 extra threads/second)
• Each .NET logical thread adds overhead
(1MB of managed memory)
.NET 4.5 Worker Threads Completion Port
Threads
Minimum 4 4
Maximum 5000 (4095) 1000
Threading in ASP.NET
Application Pool (w3wp.exe)
CLR Threadpool
Request Queue
AppDomain
Website
http.sys
IIS
Unmanaged execution
Kernel level
… …
Global Queue
connectionManagement
maxconnection
httpRuntime/
minFreeThreads
minLocalRequestFreeThreads
processModel/
maxWorkerThreads
minWorkerThreads
maxIoThreads
Outgoing connections
applicationPool/
maxConcurrentRequestsPerCpu
Worker
Threads
Completion
Port Threads
Making a choice for (a)sync
Synchronous
• Operations are simple or
short-running
• Simplicity over efficiency
• CPU-bound operations
Asynchronous
• Ability to cancel long-
running tasks
• Parallelism over simplicity
• Blocking operations are
bottleneck for
performance
• Network or I/O bound
operations
Worker thread #1 Worker thread #2Worker thread #3 IO Completion Port
Thread #3
Threads types and context switches
ASP.NET
Runtime
Store
Customers
Async
Windows IO
Completion
Port
db.Save
ChangesAsync
Must support async pattern
in some way
As an example,
Entity Framework 6 has
support for async operations
Unnecessary additional
threads only occur overhead.
Underlying SqlClient uses IO
Completion Port for async I/O
operation
Asynchronous
programming
.NET Framework support for async
History of .NET async programming
Asynchronous Programming ModelAPM
• Pairs of Begin/End methods
• Example: FileStream.BeginWrite and FileStream.EndWrite
• Convert using TaskFactory and TaskFactory<TResult>
Event-based Asynchronous PatternEAP
• Pairs of OperationAsync method and OperationCompleted event
• Example: WebClient.DownloadStringAsync and WebClient.DownloadStringCompleted
• TaskCompletionSource<T> to the rescue
Task-based Asynchronous PatternTAP
• Task and Task<T>
• Preferred model
Async in .NET BCL classes
• .NET Framework classes show each async style
• Sometimes even mixed
• Example: System.Net.WebClient
• TPL (Task-based) APIs are preferred
• Find and use new classes that support TAP natively
Async constructs in ASP.NET
• ASP.NET runtime
• Async Modules
• Async Handlers
• ASP.NET WebForms
• AddOnPreRenderComplete
• PageAsyncTask
• ASP.NET MVC and WebAPI
• Async actions
ASP.NET WebForms
ASP.NET specifics part 1
Asynchronous programming in
WebForms
Your options:
1. Asynchronous
pages
2. AsyncTasks
It all comes down to hooking into async page lifecycle
Normal synchronous page lifecycle
for ASP.NET WebForms
…
…
LoadComplete
PreRender
PreRenderComplete
SaveViewState
Client
Request
page
Send response
Render
…
Thread 1
Switch to asynchronous handling
…
…
LoadComplete
PreRender
PreRenderComplete
SaveViewState
Client
Send response
Render
…
Thread 1
Thread 2
IAsyncResult
Request
page
Async pages in WebForms
Recipe for async pages
• Add async="true" to @Page directive or <pages> element in
web.config
• Pass delegates for start and completion of asynchronous operation
in AddOnPreRenderCompleteAsync method
• Register event handler for PreRenderComplete
private void Page_Load(object sender, EventArgs e)
{
this.AddOnPreRenderCompleteAsync(
new BeginEventHandler(BeginAsynchronousOperation),
new EndEventHandler(EndAsynchronousOperation));
this.PreRenderComplete += new
EventHandler(LongRunningAsync_PreRenderComplete);
}
PageAsyncTasks
• Single unit of work
• Encapsulated by PageAsyncTask class
• Support for APM and TPL (new in ASP.NET 4.5)
• Preferred way over async void event handlers
• Can run multiple tasks in parallel
// TAP async delegate as Page task
RegisterAsyncTask(new PageAsyncTask(async (token) =>
{
await Task.Delay(3000, token);
}));
ASP.NET MVC and
WebAPI
ASP.NET specifics part 2
Async support in MVC
• AsyncController (MVC3+)
• Split actions in two parts
1. Starting async: void IndexAsync()
2. Completing async: ActionResult IndexCompleted(…)
• AsyncManager
• OutstandingOperations Increment and Decrement
• Task and Task<ActionResult> (MVC 4+)
• Async and await (C# 5+)
Async actions in ASP.NET MVC
From synchronous
public ActionResult Index()
{
// Call synchronous operations
return View("Index", GetResults());
}
To asynchronous
public async Task<ActionResult> IndexAsync()
{
// Call operations asynchronously
return View("Index", await GetResultsAsync());
}
Timeouts
• Timeouts apply to synchronous handlers
• Default timeout is 110 seconds
(90 for ASP.NET 1.0 and 1.1)
• MVC and WebAPI are always asynchronous
• Even if you only use synchronous handlers
• (Server script) timeouts do not apply
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5" executionTimeout="5000" />
</system.web>
Timeouts in MVC and WebAPI
• Use AsyncTimeoutAttribute on async actions
• When timeout occurs TimeoutException is thrown
from action
• Default timeout is AsyncManager’s 45000 milliseconds
• Might want to catch errors
[AsyncTimeout(2000)]
[HandleError(ExceptionType=typeof(TimeoutException))]
public async Task<ActionResult> SomeMethodAsync(CancellationToken token)
{
// Pass down CancellationToken to other async method calls
…
}
ASP.NET SignalR async notes
• In-memory message bus is very fast
• Team decided not to make it async
• Sending to clients is
• always asynchronous
• on different call-stack
Beware of the async gotchas
• Cannot catch exceptions in async void methods
• Mixing sync/async can deadlock threads in ASP.NET
• Suboptimal performance for regular awaits
Best practices for async:
• Avoid async void
• Async all the way
• Configure your wait
Tips
• Don’t do 3 gotcha’s
• Avoid blocking threads and thread starvation
• Remember I/O bound (await)
vs. CPU bound (ThreadPool, Task.Run, Parallel.For)
• Thread management:
• Avoid creating too many
• Create where needed and reuse if possible
• Try to switch to IO Completion Port threads
• Look for BCL support
Summary
• Make sure you are comfortable with
• Multi-threading, parallelism, concurrency, async and await
• ASP.NET fully supports TPL and async/await
• WebForms
• MVC
• WebAPI
• Great performance and scalability comes from
good thread management
• Be aware of specific ASP.NET behavior
Questions? Answers!

More Related Content

PPTX
ASP.NET vNext
PPTX
MVC 6 - the new unified Web programming model
PPTX
Run your Dockerized ASP.NET application on Windows and Linux!
PPTX
Angular Owin Katana TypeScript
PPTX
Coordinating Micro-Services with Spring Cloud Contract
PPTX
What’s expected in Spring 5
ODP
Developing Microservices using Spring - Beginner's Guide
PDF
PyCon India 2012: Celery Talk
ASP.NET vNext
MVC 6 - the new unified Web programming model
Run your Dockerized ASP.NET application on Windows and Linux!
Angular Owin Katana TypeScript
Coordinating Micro-Services with Spring Cloud Contract
What’s expected in Spring 5
Developing Microservices using Spring - Beginner's Guide
PyCon India 2012: Celery Talk

What's hot (20)

PDF
Open stack ocata summit enabling aws lambda-like functionality with openstac...
PPTX
Jeffrey Richter
PPTX
Containerize all the things!
PDF
Serverless Node.js
PPTX
Microsoft ASP.NET 5 - The new kid on the block
PPTX
A Whirldwind Tour of ASP.NET 5
PPTX
Node.js Chapter1
PDF
Securing Containers From Day One | null Ahmedabad Meetup
PDF
Microservices with AWS Lambda and the Serverless Framework
PPTX
A brief intro to nodejs
PDF
Delivering big content at NBC News with RavenDB
PPTX
Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...
PDF
Introduction to Micronaut - JBCNConf 2019
PDF
Gradual migration to MicroProfile
PPTX
Beginners Node.js
PDF
TDD a REST API With Node.js and MongoDB
PDF
Service discovery with Eureka and Spring Cloud
PPTX
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
PDF
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
PDF
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Open stack ocata summit enabling aws lambda-like functionality with openstac...
Jeffrey Richter
Containerize all the things!
Serverless Node.js
Microsoft ASP.NET 5 - The new kid on the block
A Whirldwind Tour of ASP.NET 5
Node.js Chapter1
Securing Containers From Day One | null Ahmedabad Meetup
Microservices with AWS Lambda and the Serverless Framework
A brief intro to nodejs
Delivering big content at NBC News with RavenDB
Part 3 of the REAL Webinars on Oracle Cloud Native Application Development (J...
Introduction to Micronaut - JBCNConf 2019
Gradual migration to MicroProfile
Beginners Node.js
TDD a REST API With Node.js and MongoDB
Service discovery with Eureka and Spring Cloud
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
Javantura v4 - (Spring)Boot your application on Red Hat middleware stack - Al...
Ad

Viewers also liked (12)

PDF
DIABETES_E-Packet-2
PPTX
Async Programming with C#5: Basics and Pitfalls
PPTX
Ppt flashin
PPT
серкеноваулжан+кулинарнаяшкола+клиенты
PDF
Near_Neighbours_Coventry_University_Evaluation (1)
PDF
Padilla sosa lizeth_margarita_tarea3
PPTX
хакимкаиргельды+компания+клиенты
PPTX
Comment intégrer les switch Nebula à votre réseau
PPTX
Padilla sosa lizeth_margarita_tarea12
ODP
Zappa_Brand_Jap_Pre
PDF
M ate3 multiplicacion
DOC
DIABETES_E-Packet-2
Async Programming with C#5: Basics and Pitfalls
Ppt flashin
серкеноваулжан+кулинарнаяшкола+клиенты
Near_Neighbours_Coventry_University_Evaluation (1)
Padilla sosa lizeth_margarita_tarea3
хакимкаиргельды+компания+клиенты
Comment intégrer les switch Nebula à votre réseau
Padilla sosa lizeth_margarita_tarea12
Zappa_Brand_Jap_Pre
M ate3 multiplicacion
Ad

Similar to Asynchronous programming in ASP.NET (20)

PPTX
10 tips to make your ASP.NET Apps Faster
PPTX
End to-end async and await
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
PPTX
Training – Going Async
PPTX
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
PPTX
What's New in .Net 4.5
PPTX
Task parallel library presentation
PPTX
Advance java session 20
PPTX
Using MVC with Kentico 8
PPTX
PPTX
Async Programming in C# 5
PDF
Ratpack Web Framework
PPTX
Windows 8 Metro apps and the outside world
PPTX
Workflow All the Things with Azure Logic Apps
PPTX
Orchestration service v2
PDF
Servlet and JSP
PPT
JAVA Servlets
PDF
Apache Samza 1.0 - What's New, What's Next
PPTX
History of asynchronous in .NET
10 tips to make your ASP.NET Apps Faster
End to-end async and await
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Training – Going Async
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
What's New in .Net 4.5
Task parallel library presentation
Advance java session 20
Using MVC with Kentico 8
Async Programming in C# 5
Ratpack Web Framework
Windows 8 Metro apps and the outside world
Workflow All the Things with Azure Logic Apps
Orchestration service v2
Servlet and JSP
JAVA Servlets
Apache Samza 1.0 - What's New, What's Next
History of asynchronous in .NET

More from Alex Thissen (16)

PPTX
Go (con)figure - Making sense of .NET configuration
PPTX
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
PPTX
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
PPTX
Health monitoring and dependency injection - CNUG November 2019
PPTX
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
PPTX
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
PPTX
It depends: Loving .NET Core dependency injection or not
PPTX
Overview of the new .NET Core and .NET Platform Standard
PPTX
Exploring Microservices in a Microsoft Landscape
PPTX
How Docker and ASP.NET Core will change the life of a Microsoft developer
PPTX
Visual Studio Productivity tips
PPTX
Exploring microservices in a Microsoft landscape
PPTX
Visual Studio 2015 experts tips and tricks
PPTX
ASP.NET 5 - Microsoft's Web development platform reimagined
PPTX
//customer/
PPTX
.NET Core: a new .NET Platform
Go (con)figure - Making sense of .NET configuration
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Health monitoring and dependency injection - CNUG November 2019
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
It depends: Loving .NET Core dependency injection or not
Overview of the new .NET Core and .NET Platform Standard
Exploring Microservices in a Microsoft Landscape
How Docker and ASP.NET Core will change the life of a Microsoft developer
Visual Studio Productivity tips
Exploring microservices in a Microsoft landscape
Visual Studio 2015 experts tips and tricks
ASP.NET 5 - Microsoft's Web development platform reimagined
//customer/
.NET Core: a new .NET Platform

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Nekopoi APK 2025 free lastest update
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Online Work Permit System for Fast Permit Processing
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
System and Network Administration Chapter 2
ManageIQ - Sprint 268 Review - Slide Deck
Nekopoi APK 2025 free lastest update
2025 Textile ERP Trends: SAP, Odoo & Oracle
CHAPTER 2 - PM Management and IT Context
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Understanding Forklifts - TECH EHS Solution
Navsoft: AI-Powered Business Solutions & Custom Software Development
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Online Work Permit System for Fast Permit Processing
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Softaken Excel to vCard Converter Software.pdf
Transform Your Business with a Software ERP System
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
System and Network Administration Chapter 2

Asynchronous programming in ASP.NET

  • 3. Agenda • Introduction on synchronicity • Threading and async programming in .NET • Details for • ASP.NET WebForms • ASP.NET MVC • ASP.NET WebAPI • ASP.NET SignalR • Gotchas • Questions and Answers
  • 4. Talking about synchronicity Primer on async and multi-threading in Windows and .NET
  • 5. (A)Synchronous in a web world Message Exchange Patterns Parallelization vs. multi- threading High Latency vs high throughput Asynchronicity is easy now Blocking operations Asynchronous is faster
  • 6. A tale of fast food restaurants
  • 7. Threading in Windows and .NET • Two concurrency types in Windows Operating System 1. Worker threads Physical units of work 2. IO Completion Ports Special construct for async I/O bound operations • Threads incur overhead • But threads waiting for IO Completion Port are efficient
  • 8. .NET Threading primitives • System.Threading namespace • Threads: Thread and ThreadPool • Locks: Mutex, WaitHandle, Semaphore, Monitor, Interlocked • ThreadPool cannot scale hard (2 extra threads/second) • Each .NET logical thread adds overhead (1MB of managed memory) .NET 4.5 Worker Threads Completion Port Threads Minimum 4 4 Maximum 5000 (4095) 1000
  • 9. Threading in ASP.NET Application Pool (w3wp.exe) CLR Threadpool Request Queue AppDomain Website http.sys IIS Unmanaged execution Kernel level … … Global Queue connectionManagement maxconnection httpRuntime/ minFreeThreads minLocalRequestFreeThreads processModel/ maxWorkerThreads minWorkerThreads maxIoThreads Outgoing connections applicationPool/ maxConcurrentRequestsPerCpu Worker Threads Completion Port Threads
  • 10. Making a choice for (a)sync Synchronous • Operations are simple or short-running • Simplicity over efficiency • CPU-bound operations Asynchronous • Ability to cancel long- running tasks • Parallelism over simplicity • Blocking operations are bottleneck for performance • Network or I/O bound operations
  • 11. Worker thread #1 Worker thread #2Worker thread #3 IO Completion Port Thread #3 Threads types and context switches ASP.NET Runtime Store Customers Async Windows IO Completion Port db.Save ChangesAsync Must support async pattern in some way As an example, Entity Framework 6 has support for async operations Unnecessary additional threads only occur overhead. Underlying SqlClient uses IO Completion Port for async I/O operation
  • 13. History of .NET async programming Asynchronous Programming ModelAPM • Pairs of Begin/End methods • Example: FileStream.BeginWrite and FileStream.EndWrite • Convert using TaskFactory and TaskFactory<TResult> Event-based Asynchronous PatternEAP • Pairs of OperationAsync method and OperationCompleted event • Example: WebClient.DownloadStringAsync and WebClient.DownloadStringCompleted • TaskCompletionSource<T> to the rescue Task-based Asynchronous PatternTAP • Task and Task<T> • Preferred model
  • 14. Async in .NET BCL classes • .NET Framework classes show each async style • Sometimes even mixed • Example: System.Net.WebClient • TPL (Task-based) APIs are preferred • Find and use new classes that support TAP natively
  • 15. Async constructs in ASP.NET • ASP.NET runtime • Async Modules • Async Handlers • ASP.NET WebForms • AddOnPreRenderComplete • PageAsyncTask • ASP.NET MVC and WebAPI • Async actions
  • 17. Asynchronous programming in WebForms Your options: 1. Asynchronous pages 2. AsyncTasks It all comes down to hooking into async page lifecycle
  • 18. Normal synchronous page lifecycle for ASP.NET WebForms … … LoadComplete PreRender PreRenderComplete SaveViewState Client Request page Send response Render … Thread 1
  • 19. Switch to asynchronous handling … … LoadComplete PreRender PreRenderComplete SaveViewState Client Send response Render … Thread 1 Thread 2 IAsyncResult Request page
  • 20. Async pages in WebForms Recipe for async pages • Add async="true" to @Page directive or <pages> element in web.config • Pass delegates for start and completion of asynchronous operation in AddOnPreRenderCompleteAsync method • Register event handler for PreRenderComplete private void Page_Load(object sender, EventArgs e) { this.AddOnPreRenderCompleteAsync( new BeginEventHandler(BeginAsynchronousOperation), new EndEventHandler(EndAsynchronousOperation)); this.PreRenderComplete += new EventHandler(LongRunningAsync_PreRenderComplete); }
  • 21. PageAsyncTasks • Single unit of work • Encapsulated by PageAsyncTask class • Support for APM and TPL (new in ASP.NET 4.5) • Preferred way over async void event handlers • Can run multiple tasks in parallel // TAP async delegate as Page task RegisterAsyncTask(new PageAsyncTask(async (token) => { await Task.Delay(3000, token); }));
  • 22. ASP.NET MVC and WebAPI ASP.NET specifics part 2
  • 23. Async support in MVC • AsyncController (MVC3+) • Split actions in two parts 1. Starting async: void IndexAsync() 2. Completing async: ActionResult IndexCompleted(…) • AsyncManager • OutstandingOperations Increment and Decrement • Task and Task<ActionResult> (MVC 4+) • Async and await (C# 5+)
  • 24. Async actions in ASP.NET MVC From synchronous public ActionResult Index() { // Call synchronous operations return View("Index", GetResults()); } To asynchronous public async Task<ActionResult> IndexAsync() { // Call operations asynchronously return View("Index", await GetResultsAsync()); }
  • 25. Timeouts • Timeouts apply to synchronous handlers • Default timeout is 110 seconds (90 for ASP.NET 1.0 and 1.1) • MVC and WebAPI are always asynchronous • Even if you only use synchronous handlers • (Server script) timeouts do not apply <system.web> <compilation debug="true" targetFramework="4.5"/> <httpRuntime targetFramework="4.5" executionTimeout="5000" /> </system.web>
  • 26. Timeouts in MVC and WebAPI • Use AsyncTimeoutAttribute on async actions • When timeout occurs TimeoutException is thrown from action • Default timeout is AsyncManager’s 45000 milliseconds • Might want to catch errors [AsyncTimeout(2000)] [HandleError(ExceptionType=typeof(TimeoutException))] public async Task<ActionResult> SomeMethodAsync(CancellationToken token) { // Pass down CancellationToken to other async method calls … }
  • 27. ASP.NET SignalR async notes • In-memory message bus is very fast • Team decided not to make it async • Sending to clients is • always asynchronous • on different call-stack
  • 28. Beware of the async gotchas • Cannot catch exceptions in async void methods • Mixing sync/async can deadlock threads in ASP.NET • Suboptimal performance for regular awaits Best practices for async: • Avoid async void • Async all the way • Configure your wait
  • 29. Tips • Don’t do 3 gotcha’s • Avoid blocking threads and thread starvation • Remember I/O bound (await) vs. CPU bound (ThreadPool, Task.Run, Parallel.For) • Thread management: • Avoid creating too many • Create where needed and reuse if possible • Try to switch to IO Completion Port threads • Look for BCL support
  • 30. Summary • Make sure you are comfortable with • Multi-threading, parallelism, concurrency, async and await • ASP.NET fully supports TPL and async/await • WebForms • MVC • WebAPI • Great performance and scalability comes from good thread management • Be aware of specific ASP.NET behavior

Editor's Notes

  • #10: http://support.microsoft.com/kb/821268
  • #11: http://www.asp.net/web-forms/overview/performance-and-caching/using-asynchronous-methods-in-aspnet-45
  • #22: http://blogs.msdn.com/b/pfxteam/archive/2012/05/31/what-s-new-for-parallelism-in-visual-studio-2012-rc.aspx
  • #28: http://stackoverflow.com/questions/19193451/should-signalr-server-side-methods-be-async-when-calling-clients
  • #29: http://msdn.microsoft.com/en-us/magazine/jj991977.aspx