Making the calculator thread-safe: Creating a Simple Moving Average calculator in C# - Part 2

added by DotNetKicks
5/11/2021 10:39:21 AM


In my previous post I showed how to create a Simple Moving Average calculator. The implementation was very simple, so it was conceptually easy to follow, but had a few limitations. In this post, I address some of those limitations to make the implementation thread-safe and to separate the updating of the average from the fetching of the current value.