How Functional Programming Helps With Asynchronous And Parallel Code

There is a lot of scenarios that a functional code can introduce benefits. But asynchronous and parallel programming is one of those that fit with functional programming perfectly. I’m going use one example of this in particular. That is when we write asynchronous or parallel code, we need to consciously think about how we access … 

 

Using Task.WhenAny And Task.WhenAll

In this post, we’re going to see when we should use Task.WhenAny and Task.WhenAll. I’m also going to explain the differences between Task.WaitAny and Task.WaitAll. Then I move on to show some example of good and bad usage of these constructs. We’re also going to see some situations such as when we need immediate processing … 

 

Top 7 Common Async Mistakes

There are some common mistakes that one can see over and over again while reading an asynchronous code base. This mistakes range from egregious mistakes that can halt the whole process. To mistakes that create confusion and semantically incorrect code. So in this post, I’ll gather these common mistakes into a post with the top … 

 

Asp.Net Core API: Patch Method Without Using JsonPatchDocument

Some time ago, I needed to implement a mechanism for an API to update an entity without using JsonPatchDocument. The reason was that the user of the API didn’t want to necessarily use JSON to use the patch method. But user might want to use XML, Message Pack or any other format. What I needed … 

 

When Should You Use Task.Delay

This post is about how Task.Delay can be used in different scenarios. Generally speaking we use Task.Delay to wait for specific amount of time in asynchronous fashion. I’m also going to explain why do we need to sometimes mimic this kind of behaviors. What Task.Delay Does? In some scenarios, we need to wait for specific … 

 

When to Use Async and Await and How it Works

In my last post, I discussed why asynchronous and parallel programming is becoming increasingly more important. We also saw the difference between asynchronous and parallel programming. In this post we’re going to see when asynchronous programming should be used. I’ll also show you how previous API for asynchronous programming worked. So we can see how … 

 

Concurrency Vs Parallelism

Recently I decided to start gaining more knowledge in concurrency and Parallelism in programming and go deeper as I progress in my study. I intend to share my knowledge in this areas through a series of posts that I’ll publish each month. I’ll go deeper and deeper with each post into the subject of asynchronous … 

 

.Net Exceptions Best Practices

Exception is one of those constructs that is easy to misuse. This might include not throwing exception when one should or catching the exception without a good reason. Also there is the problem of throwing the wrong exception which not only doesn’t help us, but can confuse us. On the other hand there is the … 

 

Asp.Net Core 2 Logging With Serilog And Microsoft SQL Server Sink

In this post, I’m going to describe how we can configure Serilog with Asp.Net Core 2 web and Api projects. I also configure Serilog to work with SQL Server database to store the logging information. Then I’ll write an extension method and use the built-in exception handling middleware to log exceptions in production environments. What … 

 

Policy-based Authorization Using Asp.Net Core 2 And IdentityServer4

In my previous post,  I’ve discussed how we can implement policy-based authorization to secure our API using JWT. But that wasn’t what I end-up using in production. Partly because the built-in mechanism of Asp.Net Core with JWT is not as powerful as IdentityServer4. Also I needed the single sign-on feature of  IdentityServer4. There are two …