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
Category: C#
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
C# 8 : Using Declaration
The next feature we would explore in C# 8 is more off a syntatic sugar, but neverthless it is important to understand the difference between the new syntax and the original feature it is covering up. We are all aware of the Using statements, which allows correct usage of the IDisposible objects. Using Statement Let … Continue reading C# 8 : Using Declaration
C# 8 : Index and Range
While C# as a language has grown leaps and bounds, one are that was least addressed was manipulation of collections (arrays in particular). C# 8 looks to change exactly that by introducing two new Types. System.Index System.Index is a structure that can be used to Index a collection either from the start or the end. … Continue reading C# 8 : Index and Range
Automapper – Use IoC for creating Destinations
Automapper by default creates new instances of destination using the default contructor. If you need to ask the IoC to create the new instance, it actually turns out to be pretty simple. We will begin by setting up our Unity Container to register the IMapper. As you can see, you are also initializing the Automapper … Continue reading Automapper – Use IoC for creating Destinations
Awaitable Pattern
How do you determine what types could be awaited ? That is one question that often comes to mind and the most common answer would be Task Task<TResult> void - Though it should be strictly avoided However, are we truely restricted to them ? What are the other Types that could be awaited ? The … Continue reading Awaitable Pattern
Member Serialization
Serialization at times throws curious situations that makes us look beyond the normal usages. Here is another situation that took sometime to find a solution for. Let's examine the following code. What would be the output if one was to serialize an instance of the Test class ? Let's examine the output Not surprising right … Continue reading Member Serialization
A second look at char.IsSymbol()
Let us begin by examining a rather simple looking code. What would the output of the above code ? Let's hit F5 and check it. Surprised ?? One should not feel guilty if he is surprised. It is rather surprising one does not look behind to understand what exactly char.IsSymbol does. After all, it is … Continue reading A second look at char.IsSymbol()
Deserialize Json to Generic Type
One of the recent question in stackoverflow found interesting was about a Json, which needs to be deserialized to a Generic Class. What makes the question interesting was the Generic Property would have a different Json Property name depending on the type T. Consider the following Json This needs to be Deseriliazed to the following … Continue reading Deserialize Json to Generic Type