Working with System.Random and threads safely in .NET Core and .NET Framework

added by DotNetKicks
9/6/2022 10:25:20 AM

188 Views

In this post I look at some of the ways you can misuse System.Random for generating random numbers, specifically around thread safety. I start by showing how to use the built-in thread-safe Random generator in .NET 6. I then step back to previous .NET Core implementations, before the thread-safe Random generator was added, and show how to add your own.


0 comments