private void cacheUser(User user)
{
userLock.AcquireReaderLock(Timeout.Infinite);
try
{
if (! _users.TryGetValue(user.Email,
out user))
{
userLock.UpgradeToWriterLock(Timeout.Infinite);
_users.Add(user.Email, user);
}
}
finally
{
userLock.ReleaseLock();
}
}
A couple of questions regarding the above code.
1) Is the locking being used correctly? How can I keep track of the locks? Should I use Monitor instead?
2) The collection stores a User object, but uses User.Email as the collection key, seems counter intuitive to me, any suggestions?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.