In HashBasedShortCodeGenerator you are trying to use the lock keyword to make it thread-safe and it's totally fine but I want to suggest Random.Shared.
As I know, recording to this article building-a-thread-safe-random-implementation written by @andrewlock, The humble Random class has been around since .NET Framework 1.0, but an important thing to bear in mind is that it's not thread-safe by default.
I'm going to describe. If you're generating random numbers in .NET 6+, you don't need to control the "seed" value, and you need thread-safe access, then you can use Random.Shared.
Hey @mohammadKarimi
In
HashBasedShortCodeGenerator
you are trying to use the lock keyword to make it thread-safe and it's totally fine but I want to suggestRandom.Shared
.As I know, recording to this article building-a-thread-safe-random-implementation written by @andrewlock, The humble Random class has been around since .NET Framework 1.0, but an important thing to bear in mind is that it's not thread-safe by default. I'm going to describe. If you're generating random numbers in .NET 6+, you don't need to control the "seed" value, and you need thread-safe access, then you can use
Random.Shared
.