Category: C#

Transient Exception Handling Circuit Breaker Pattern and Polly

Circuit Breaker pattern is a rather interesting pattern which was discussed in the Release It book. This pattern provides a mechanism to wrap “unpredictable code” i.e. calls to external services within a fabric that manages the execution of the actual code and takes certain actions if a certain pre-defined failure rate has been reached or […]

Read More →

Fixing Patterns for Async MVVM Applications

Download the code here –AsyncCommands If you like this post you might also like an interesting post on Deadlocks while using tasks. This post is a follow up on Stephen Cleary’s excellent post on MSDN here which is a series of articles he wrote to explain how Tasks based patterns can be effectively adopted for GUI/MVVM applications. […]

Read More →

Deadlocks when using Tasks – solved

In my last post Deadlocks when using Tasks I explained how this innocent looking piece of code can cause a GUI app to deadlock and die. I proceeded to explain the reasons behind this behaviour. In this post I aim to discuss one possible solution to this problem and highlight some potential design considerations that you […]

Read More →

Deadlocks when using Tasks

What is wrong with this code? public static class NiksMessedUpCode { private static async Task DelayAsync() { await Task.Delay(1000); } public static void Test() { // Start the delay. var delayTask = DelayAsync(); // Wait for the delay to complete. delayTask.Wait(); } }   The code compiles without errors yet there is something really terrible […]

Read More →

C# Type Constructors and Performance

At the end of my previous post on C# and code explosion within MSIL I had mentioned that when it comes to type constructors or commonly known as “static constructors”  or “class constructors” the beforefieldinit flag can considerably boost the performance of your types. This is my first post in a two part series of […]

Read More →