summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-12-26 10:11:56 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-12-26 10:11:56 -0800
commit9b1c78a3935a56ecebb142b023384943506e036f (patch)
tree90c77b1e8bea77e93f99721ef220525df29f951f /src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
parent79e45f41efa4acc686ce64624c3af4b440a5cbb5 (diff)
downloadDotNetOpenAuth-9b1c78a3935a56ecebb142b023384943506e036f.zip
DotNetOpenAuth-9b1c78a3935a56ecebb142b023384943506e036f.tar.gz
DotNetOpenAuth-9b1c78a3935a56ecebb142b023384943506e036f.tar.bz2
Fixes build break in .NET 3.5 builds.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index 388157a..e859162 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -2026,17 +2026,22 @@ namespace DotNetOpenAuth.Messaging {
/// <summary>
/// A thread-local instance of <see cref="Random"/>
/// </summary>
- private static readonly ThreadLocal<Random> threadRandom = new ThreadLocal<Random>(delegate {
- lock (threadRandomInitializer) {
- return new Random(threadRandomInitializer.Next());
- }
- });
+ [ThreadStatic]
+ private static Random threadRandom;
/// <summary>
/// Gets a random number generator for use on the current thread only.
/// </summary>
public static Random RandomNumberGenerator {
- get { return threadRandom.Value; }
+ get {
+ if (threadRandom == null) {
+ lock (threadRandomInitializer) {
+ threadRandom = new Random(threadRandomInitializer.Next());
+ }
+ }
+
+ return threadRandom;
+ }
}
}