Skip to content

Commit

Permalink
Fixes build break in .NET 3.5 builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Dec 26, 2012
1 parent 79e45f4 commit 9b1c78a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
Expand Up @@ -2026,17 +2026,22 @@ private static class ThreadSafeRandom {
/// <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;
}
}
}

Expand Down

0 comments on commit 9b1c78a

Please sign in to comment.