diff --git a/csharp/Platform.Random/Platform.Random.csproj b/csharp/Platform.Random/Platform.Random.csproj index 7701c96..9fdc245 100644 --- a/csharp/Platform.Random/Platform.Random.csproj +++ b/csharp/Platform.Random/Platform.Random.csproj @@ -4,7 +4,7 @@ LinksPlatform's Platform.Random Class Library Konstantin Diachenko Platform.Random - 0.3.0 + 0.4.0 Konstantin Diachenko net8 Platform.Random @@ -23,7 +23,7 @@ true snupkg latest - Update target framework from net7 to net8. + Replace custom Random instance with Random.Shared from .NET 6+ for improved thread safety and performance. enable diff --git a/csharp/Platform.Random/RandomHelpers.cs b/csharp/Platform.Random/RandomHelpers.cs index 93655b0..7e40c18 100644 --- a/csharp/Platform.Random/RandomHelpers.cs +++ b/csharp/Platform.Random/RandomHelpers.cs @@ -7,9 +7,9 @@ namespace Platform.Random public static class RandomHelpers { /// - /// Returns the pseudorandom number generator that is using the time of the first access to this field as seed. - /// Возвращает генератор псевдослучайных чисел использующий в качестве seed время первого обращения к этому полю. + /// Returns the shared, thread-safe pseudorandom number generator from .NET 6+. + /// Возвращает разделяемый, потокобезопасный генератор псевдослучайных чисел из .NET 6+. /// - public static readonly System.Random Default = new System.Random(System.DateTime.UtcNow.Ticks.GetHashCode()); + public static System.Random Default => System.Random.Shared; } }