Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Asynchronous Programming in C#
- Part 1
Presenter: Vikash Kumar, Mindfire Solutions
(28/07/2014)
About Me
MCTS-70-515 - Microsoft .NET 4.0, Web App
Development
MCP:70-483: MS - Programming in C#
Skills: MVC, Asp.Net Web...
Agenda

What is asynchronous?

Asynchronous programming options and history

Thread and ThreadPool

Asynchronous Progr...
What is asynchronous?
Image Source: http://www.webopedia.com/
To do more than one thing at a time.
asyn = not with
chronos...
Asynchronous programming
options and history

Thread

Asynchronous Programming Model (APM)

Event-Based Asynchronous Pa...
Thread and ThreadPool

Basic building block for async programming.

Parameterize thread, came with .NET 2.0
Image source...
APM and EAP

APM depends upon Begin and End methods.

Callbacks are dependent on IAsyncResult.

EAP came with .NET 2.0 ...
APM and EAP
Task

A task is an abstraction of unit of work to run
asynchronously.

Ways to execute: new Task(Speak).Start(),
Task.Fa...
Task error handling

Task are completed with following state: Ran to
Completion, Canceled and Faulted.

Task uses Aggreg...
Cancellation
FromAsync
Progress bar
Exception handling
Task Relationships
Task
Task Task Task
Child Tasks
Task Task Task
Chained Task
Task Relationships...

ContinueWhenXXX can be used to chain up
tasks with TaskContinuationOptions enum for
various condit...
Task Relationship
Presenter: XXXX XXXX, Mindfire Solutions
Question and
Answer
References

Pro Asynchronous Programming with .NET
 Asynchronous Programming Patterns
 Asynchronous Programming in .NET...
Presenter: Vikash Kumar, Mindfire Solutions
Thank you
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
ht...
Upcoming SlideShare
Loading in …5
×

Asynchronous Programming in C# - Part 1

1,766 views

Published on

All about asynchronous programming from .NET starting from initial framework to latest version. We will be looking into almost all features from .NET which are related to Asynchronous Programming. This seminar will cover up evolution of asynchronous programming and slowly moving to Task.

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Asynchronous Programming in C# - Part 1

  1. 1. Asynchronous Programming in C# - Part 1 Presenter: Vikash Kumar, Mindfire Solutions (28/07/2014)
  2. 2. About Me MCTS-70-515 - Microsoft .NET 4.0, Web App Development MCP:70-483: MS - Programming in C# Skills: MVC, Asp.Net WebForms, C#, EntityFramework, OpenAccess, TypeScript, SEO, jQuery, KendoUI, Lucene.Net, Asynchronous programming, Sql Server. Connect Me: Blog :- http://vikutech.blogspot.in/ Twitter :- https://twitter.com/viku85 LinkedIn :- http://www.linkedin.com/pub/vikash-kumar/11/4b5/625 Google+ :- https://plus.google.com/108754146104237310375 Contact Me: Email :- vikashk@mindfiresolutions.com / viku85@gmail.com Skype :- mfsi_vikash
  3. 3. Agenda  What is asynchronous?  Asynchronous programming options and history  Thread and ThreadPool  Asynchronous Programming Model (APM)  Event-based Asynchronous Pattern (EAP)  Task – Basics – Exception handling – Relationships
  4. 4. What is asynchronous? Image Source: http://www.webopedia.com/ To do more than one thing at a time. asyn = not with chronos = time
  5. 5. Asynchronous programming options and history  Thread  Asynchronous Programming Model (APM)  Event-Based Asynchronous Pattern (EAP)  BackgroundWorker  Task  Task Parallel Library - DataFlow  Task Parallel Library – Parallel APIs  Thread → APM → EAP → TAP
  6. 6. Thread and ThreadPool  Basic building block for async programming.  Parameterize thread, came with .NET 2.0 Image source:http://johnpaulmorabito.blogspot.in/
  7. 7. APM and EAP  APM depends upon Begin and End methods.  Callbacks are dependent on IAsyncResult.  EAP came with .NET 2.0 which automatically handles synchronization context.  BackgroundWorker is an example of EAP based programming.  EAP can be seen while adding web reference which automatically creates with proxies classes.
  8. 8. APM and EAP
  9. 9. Task  A task is an abstraction of unit of work to run asynchronously.  Ways to execute: new Task(Speak).Start(), Task.Factory.StartNew(Speak), Task.Run(Speak)  Use FromAsync when an API has BeginXXX/EndXXX.  Task can be canceled through CancellationToken and checked with ThrowIfCancellationRequested.  IProgress<T> came with 4.5 which can be used to show status
  10. 10. Task error handling  Task are completed with following state: Ran to Completion, Canceled and Faulted.  Task uses AggregateException to wrap up any other exception occurs which can be found under inner exception.  AggregateException comes with Flatten method to check all exceptions.  AggregateException also comes with Handle method which accepts predicate to handle errors.  ThrowUnobservedTaskExceptions to configure to shallow exception.
  11. 11. Cancellation FromAsync
  12. 12. Progress bar Exception handling
  13. 13. Task Relationships Task Task Task Task Child Tasks Task Task Task Chained Task
  14. 14. Task Relationships...  ContinueWhenXXX can be used to chain up tasks with TaskContinuationOptions enum for various conditions.  TaskCreationOptions.AttachedToParent is used to create child tasks.  Creating child task will reflect exception in parent task if exception occurs.  Task.Run uses TaskCreationOptions.DenyChildAttach by default which will act as nested task.
  15. 15. Task Relationship
  16. 16. Presenter: XXXX XXXX, Mindfire Solutions Question and Answer
  17. 17. References  Pro Asynchronous Programming with .NET  Asynchronous Programming Patterns  Asynchronous Programming in .NET: I'll Call You Bac (For definition)
  18. 18. Presenter: Vikash Kumar, Mindfire Solutions Thank you
  19. 19. www.mindfiresolutions.com https://www.facebook.com/MindfireSolutions http://www.linkedin.com/company/mindfire-solutions http://twitter.com/mindfires

×