SlideShare a Scribd company logo
a tour of




Asynchronous Programming
[Async CTP 3]
srikanth@brainscale.com/vishwanath.srikanth@gmail.com


Vishwanath.srikanth


Vishsrikanth


Vishwanathsrikanth.wordpress.com
                                   Vishwanath Srikanth
Topics for this Presentation


 Earlier ways    Awaiting Task            Task based
   of Async     asynchronously           Programming




                   We have features for every step of the way
EARLIER WAYS OF PROGRAMMING
ASYNC
Async Programming

Why do we need async?
• Responsive UI.
• Leverage Computing Power.
• Better Utilization of Resources.
• Better user experience.

 What is expected from Async programming patterns?
 • Transparent Remote operations
 • Easy to code
 • Cancellations, Timeouts, Preserving threads during blocking awaits etc.
Pre matured ways of async programming.

 Recommended Async Programming Concepts
 • Don’t wait for the response.
 • Return immediately after issuing a async request
 • Let the response call you back.

 Earlier ways
 • IAsyncResult Pattern Ex: BeginRead, EndRead
 • Event based Asynchronous pattern

                                                      Sync




                                                        Async
Pre matured ways of async programming.

 What went wrong?

 •   Disruptive Program Structure
 •   Error prone
 •   Heavy weight
 •   Difficult to design and write
New way of Async Programming DEMO
Awaiting a   AWAITING TASK ASYNCHRONOUSLY
  Task
What is Async CTP?

• A new language feature
• New framework pattern



What do you need to start working on
Async CTP

• Visual Studio 2011 Beta
• Visual Studio 2010 SP1 with Async
   CTP
Download from:
http://www.microsoft.com/download/e
n/details.aspx?id=9983
Task and Task<T>

 •   A Task is a representation of ongoing work
 •   Available in .NET 4
 •   Task returns nothing, Task<T> returns a result of type T.
 •   Normal tasks - Independent of Thread.

 • Async tasks run on same thread.




 • Propagate Exceptions
‘async’ modifier

 • Indicates Asynchrony
 • Can be used for methods or Events or Methods or Lambdas




 • Out and ref are not allowed.
 • Analogous to ‘yield’
‘await’ keyword

 • Await - Prepend to a method which can return Task, Task<T>
 • Everything that continues is compiled asynchronously
 • ‘Async’ Runs synchronously until first ‘await’.
Task based
Programming   TASK BASED ASYNC PATTERN
Task based async pattern

                            Async                                UI Thread
   Caller
                           Method
            Task/Task<T>

                             Create Task &
                                                  Check for callback

                            Wait for ‘await’
                                                  Load the Context

                            Capture Context           continue


                           Sign up a call back.
Task Based Asynchronous Pattern (TAP)

 • Task Behavior – Initialization, Exceptions, Target Environment, TaskStatus
 • Task States
     • Created, WaitingForActivation, WaitingToRun, Running,
        WaitingForChildrenToComplete, RanToCompletion, Canceled, Faulted.
 • Cancellation
 • Cancellations



 • Progress Reporting


 • Testable
 • TaskID
 • Task Creation Options – None, Prefairness, LongRunning, AttachedToParent
Consuming the Task Based Asynchronous Pattern

 • Continue Await using continuewith
 • Task.Yield()
 • Cancel Context - ConfigureAwait


 • Cancellation
     • Cancellation.None
 • Progress Reporting
Building Task-Based Combinators

Task.Run




Task.WhenAll



 - Aggregate Exception or All Exceptions
Building Task-Based Combinators
 Task.FromResult




 Task.WhenAny

  •   Redundancy
  •   Interleaving
  •   Throttling
  •   Early bailout
Questions



            Thank you!
There is more….

 Goodies……

 • Which namespace does Task belongs to ?
 • Can we utilize the power of multicore using
   Tasks?

More Related Content

PDF
Async Await for Mobile Apps
PDF
Using Async in your Mobile Apps - Marek Safar
PPTX
Automation of Deep learning training with AWS Step Functions
PPTX
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
PDF
How LogicMonitor Automates Deployments with Bamboo and Ansible
PPT
Asynchronous Programming in C# - Part 1
PPTX
High Performance Serverless Functions in Scala
PDF
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Async Await for Mobile Apps
Using Async in your Mobile Apps - Marek Safar
Automation of Deep learning training with AWS Step Functions
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
How LogicMonitor Automates Deployments with Bamboo and Ansible
Asynchronous Programming in C# - Part 1
High Performance Serverless Functions in Scala
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit

What's hot (20)

PPTX
Elm - never get a runtime error anymore. Almost.
PDF
Serverless Application Model - Executing Lambdas Locally
PDF
Reasonable app development
PDF
NCUG 2019: Super charge your API’s with Reactive streams
PDF
[CocoaHeads Tricity] Andrzej Dąbrowski - Dependency injection and testable ar...
PPTX
Dev-Friendly Ops
PPTX
CSharp 5 Async
PPTX
Batch Apex in Salesforce
PPTX
Performance Monitoring with AOP and Amazon CloudWatch
PPTX
Signal r azurepresentation
PDF
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
PDF
Variables in Pharo5
PDF
Introduction to Functional Reactive Programming
PPTX
Asynchronous programming in ASP.NET
PPTX
Why I am hooked on the future of React
PDF
AWS Lambda Function with Kotlin
PDF
Anatomy of a Reactive Application
PPTX
Chatbots with Serverless
PPTX
How to deploy your Apps in serverless-way using App Engine.pptx
PPTX
Spotify's Music Recommendations Lambda Architecture
Elm - never get a runtime error anymore. Almost.
Serverless Application Model - Executing Lambdas Locally
Reasonable app development
NCUG 2019: Super charge your API’s with Reactive streams
[CocoaHeads Tricity] Andrzej Dąbrowski - Dependency injection and testable ar...
Dev-Friendly Ops
CSharp 5 Async
Batch Apex in Salesforce
Performance Monitoring with AOP and Amazon CloudWatch
Signal r azurepresentation
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Variables in Pharo5
Introduction to Functional Reactive Programming
Asynchronous programming in ASP.NET
Why I am hooked on the future of React
AWS Lambda Function with Kotlin
Anatomy of a Reactive Application
Chatbots with Serverless
How to deploy your Apps in serverless-way using App Engine.pptx
Spotify's Music Recommendations Lambda Architecture
Ad

Similar to Async CTP 3 Presentation for MUGH 2012 (20)

PPTX
Training – Going Async
PPTX
Task parallel library presentation
PPTX
End to-end async and await
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
PPT
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
PDF
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
PPTX
Async programming and python
PPTX
C# Async/Await Explained
PPTX
Asynchronous programming - .NET Way
PDF
Writing Asynchronous Programs with Scala & Akka
PDF
we45 DEFCON Workshop - Building AppSec Automation with Python
PPTX
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
PPTX
Asynchronous Programming in .NET
PPTX
C# 5 deep drive into asynchronous programming
PDF
Rethinking the debugger
PPTX
Async programming in c#
PDF
Rundown of Async/Await in Rust
PDF
Rust's Journey to Async/await
PPTX
Ddd melbourne 2011 C# async ctp
Training – Going Async
Task parallel library presentation
End to-end async and await
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
C# Async on iOS and Android - Craig Dunn, Developer Evangelist at Xamarin
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Async programming and python
C# Async/Await Explained
Asynchronous programming - .NET Way
Writing Asynchronous Programs with Scala & Akka
we45 DEFCON Workshop - Building AppSec Automation with Python
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
Asynchronous Programming in .NET
C# 5 deep drive into asynchronous programming
Rethinking the debugger
Async programming in c#
Rundown of Async/Await in Rust
Rust's Journey to Async/await
Ddd melbourne 2011 C# async ctp
Ad

More from Sri Kanth (7)

PPTX
Run UI Automation Tests using Selenium Grid and Azure Container Service (AKS)
PPTX
Build Proactive bot using Microsoft Bot Framework
PPTX
Windows Server Containers
PPTX
Windows server containers
PPTX
Windows server containers
PPTX
Big data and hadoop
PPTX
Introducing
Run UI Automation Tests using Selenium Grid and Azure Container Service (AKS)
Build Proactive bot using Microsoft Bot Framework
Windows Server Containers
Windows server containers
Windows server containers
Big data and hadoop
Introducing

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
NewMind AI Monthly Chronicles - July 2025
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

Async CTP 3 Presentation for MUGH 2012

  • 1. a tour of Asynchronous Programming [Async CTP 3]
  • 3. Topics for this Presentation Earlier ways Awaiting Task Task based of Async asynchronously Programming We have features for every step of the way
  • 4. EARLIER WAYS OF PROGRAMMING ASYNC
  • 5. Async Programming Why do we need async? • Responsive UI. • Leverage Computing Power. • Better Utilization of Resources. • Better user experience. What is expected from Async programming patterns? • Transparent Remote operations • Easy to code • Cancellations, Timeouts, Preserving threads during blocking awaits etc.
  • 6. Pre matured ways of async programming. Recommended Async Programming Concepts • Don’t wait for the response. • Return immediately after issuing a async request • Let the response call you back. Earlier ways • IAsyncResult Pattern Ex: BeginRead, EndRead • Event based Asynchronous pattern Sync Async
  • 7. Pre matured ways of async programming. What went wrong? • Disruptive Program Structure • Error prone • Heavy weight • Difficult to design and write
  • 8. New way of Async Programming DEMO
  • 9. Awaiting a AWAITING TASK ASYNCHRONOUSLY Task
  • 10. What is Async CTP? • A new language feature • New framework pattern What do you need to start working on Async CTP • Visual Studio 2011 Beta • Visual Studio 2010 SP1 with Async CTP Download from: http://www.microsoft.com/download/e n/details.aspx?id=9983
  • 11. Task and Task<T> • A Task is a representation of ongoing work • Available in .NET 4 • Task returns nothing, Task<T> returns a result of type T. • Normal tasks - Independent of Thread. • Async tasks run on same thread. • Propagate Exceptions
  • 12. ‘async’ modifier • Indicates Asynchrony • Can be used for methods or Events or Methods or Lambdas • Out and ref are not allowed. • Analogous to ‘yield’
  • 13. ‘await’ keyword • Await - Prepend to a method which can return Task, Task<T> • Everything that continues is compiled asynchronously • ‘Async’ Runs synchronously until first ‘await’.
  • 14. Task based Programming TASK BASED ASYNC PATTERN
  • 15. Task based async pattern Async UI Thread Caller Method Task/Task<T> Create Task & Check for callback Wait for ‘await’ Load the Context Capture Context continue Sign up a call back.
  • 16. Task Based Asynchronous Pattern (TAP) • Task Behavior – Initialization, Exceptions, Target Environment, TaskStatus • Task States • Created, WaitingForActivation, WaitingToRun, Running, WaitingForChildrenToComplete, RanToCompletion, Canceled, Faulted. • Cancellation • Cancellations • Progress Reporting • Testable • TaskID • Task Creation Options – None, Prefairness, LongRunning, AttachedToParent
  • 17. Consuming the Task Based Asynchronous Pattern • Continue Await using continuewith • Task.Yield() • Cancel Context - ConfigureAwait • Cancellation • Cancellation.None • Progress Reporting
  • 18. Building Task-Based Combinators Task.Run Task.WhenAll - Aggregate Exception or All Exceptions
  • 19. Building Task-Based Combinators Task.FromResult Task.WhenAny • Redundancy • Interleaving • Throttling • Early bailout
  • 20. Questions Thank you!
  • 21. There is more…. Goodies…… • Which namespace does Task belongs to ? • Can we utilize the power of multicore using Tasks?