Asynchronous Code – Behind the Scenes – 004

During this series of deep dive into the asynchronous calls, we have so far looked into [x] General Structure of generated code.[x] Role of Stub/Worker method.[x] Structure of State Machine and role of Fields.[x] Implementation of the SetStateMachine method.[ ] Implementation of the MoveNext method. It is now time to look at the most important piece of the puzzle … Continue reading Asynchronous Code – Behind the Scenes – 004

Advertisement

Asynchronous Code – Behind the Scenes – 003

Okay, I wasn't quite realistic in the earlier post when I mentioned we would look at MoveNext in this one. I missed an important clog of the wheel. The SetStateMachine() method. IAsyncStateMachine.SetStateMachine We will only breifly visit the SetStateMachine method here, as the complete picture becomes more clear when we look to details of the MoveNext() method. So how does the SetStateMachine method … Continue reading Asynchronous Code – Behind the Scenes – 003

Asynchronous Code – Behind the Scenes – 002

In the earlier part of this series, we reviewed the generic structure of decompiled async code, especially the stub method. In this part, we would continue our explore of async code and look into the State Machine. We would not delve deep into the most important MoveNext() method yet, we will first familiar with the different parts … Continue reading Asynchronous Code – Behind the Scenes – 002

TPL And Asynchronous Programming

This series follows my study notes on TPL and asynchronous programming. A special thanks to Jon Skeets and Jeffrey Richter for their wonderful books,which has been the inspirations behind this series. Overhead of explicit ThreadsAwaitable PatternException Handling in async methodsAsynchronous Code - Behind the scenes - 001Asynchronous Code - Behind the scenes - 002Asynchronous Code … Continue reading TPL And Asynchronous Programming

Asynchronous Code – Behind the Scenes – 001

If you were to ask me what was the biggest milestone in .Net development, then my choice would definetly be .Net 5.0 - especially the introduction of the async/await. The more you learn about the underlying working, you cannot but stop and admire the efforts done by the lang uage developers to make our life easier. … Continue reading Asynchronous Code – Behind the Scenes – 001

Revisiting Exception Handling in async methods

It is interesting to observe how the Exceptions behave in async code. While the .Net framework attempts to ensure the exprerience of handling failures in async methods are as similar to the synchronous methods, there are subtle differences which is worth understanding. Let us examine the following code. async Task<string> Foo() { var client = … Continue reading Revisiting Exception Handling in async methods

Early Exceptions for Iterator and async Methods

One of the first things you would need to be vary of while working with Iterator methods and async methods is exception handling. Both Iterator methods and async methods delay the execution of your code, right until you need the result, but it also results in delayed exceptions. Late Exception With Iterator Methods Let's consider … Continue reading Early Exceptions for Iterator and async Methods

Allocation free ‘async’ Methods

Task Asynchronous Programming (TAP) model will go down as one of the landmark of C# language revolution. The typical method signature with return type Task/Task<T> has since then made significant appearances in our programming life. But despite all its glorious functionalities, it needs to be noted that it comes at a certain cost - performance … Continue reading Allocation free ‘async’ Methods