RSS Search

News  Feeds  Tags  Search Shortcuts

FeedsFarm.com > This code smells

This code smells

13th Nov 2006, 08:21 GMT

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?

View full story at channel9.msdn.com

This code smells related news:

Latest news from Channel 9: