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 : https://www.nuget.org/packages/ThreadSafeObject/
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(); c.Add();
And you want
to be thread safe
In the Package Manager Console write:
Then modify your code to:
Calculation c = new Calculation(); dynamic ts = new ThreadSafe(c); ts.Add();
It is a toy project- however, it has tests to prove it is correct.
You can download the code source from https://github.com/ignatandrei/ThreadSafeObject/