File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,19 @@ internal static class Random
22
22
/// <summary>
23
23
/// A instance of <see cref="Random"/>
24
24
/// </summary>
25
+ [ ThreadStatic ]
25
26
private static readonly System . Random Rnd ;
26
27
27
28
/// <summary>
28
29
/// Initializes static members of the <see cref="Random"/> class.
29
30
/// </summary>
30
31
static Random ( )
31
32
{
32
- #if NET3X || NETSTD
33
+ #if NETSTD
33
34
Rnd = new System . Random ( ) ;
34
35
#else
35
- Rnd = ThreadSafeRandomProvider . GetThreadRandom ( ) ;
36
+ int seed = Environment . TickCount ;
37
+ Rnd = new System . Random ( Interlocked . Increment ( ref seed ) ) ;
36
38
#endif
37
39
}
38
40
@@ -125,20 +127,4 @@ internal static long NextLong()
125
127
return BitConverter . ToInt64 ( buf , 0 ) ;
126
128
}
127
129
}
128
-
129
- #if ( ! NET3X && ! NETSTD )
130
- public static class ThreadSafeRandomProvider
131
- {
132
- private static int _seed = Environment . TickCount ;
133
-
134
- private static readonly ThreadLocal < System . Random > _randomWrapper = new ThreadLocal < System . Random > ( ( ) =>
135
- new System . Random ( Interlocked . Increment ( ref _seed ) )
136
- ) ;
137
-
138
- public static System . Random GetThreadRandom ( )
139
- {
140
- return _randomWrapper . Value ;
141
- }
142
- }
143
- #endif
144
130
}
Original file line number Diff line number Diff line change @@ -12,8 +12,6 @@ namespace Tynamix.ObjectFiller
12
12
using System ;
13
13
using System . Collections . Generic ;
14
14
using System . Linq ;
15
- using System . Reflection ;
16
- using System . Runtime . CompilerServices ;
17
15
18
16
/// <summary>
19
17
/// This class is a easy way to get random values.
You can’t perform that action at this time.
0 commit comments