roadie/Roadie.Api.Library/Utility/StaticRandom.cs
Steven Hildreth 1448b0dbb3 resolves #21
2019-07-18 10:52:00 -05:00

18 lines
No EOL
457 B
C#

using System;
using System.Threading;
namespace Roadie.Library.Utility
{
public static class StaticRandom
{
private static readonly ThreadLocal<Random> threadLocal = new ThreadLocal<Random> (() => new Random(Interlocked.Increment(ref seed)));
private static int seed;
public static Random Instance => threadLocal.Value;
static StaticRandom()
{
seed = Environment.TickCount;
}
}
}