Making any call to a function of an object thread safe



I was wondering how to modify old code to support threads /task .

So I was making a small project about making any function of an object thread safe.

NuGet Package at :

The solution contain tests and 2 console project for .NET Core and .NET Framework 4.5.1

The usage is pretty easy

Let’s say you have this

Calculation c = new Calculation();

And you want


to be thread safe

In the Package Manager Console write:

Install-Package ThreadSafeObject

Then modify your code to:

Calculation c = new Calculation();
dynamic ts = new ThreadSafe(c);

It is a toy project- however, it has tests to prove it is correct.

You can download the code source from