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?
This code smells related news:
- Live Online Chat - Improve Your Code Quality - Friday, Nov. 17th 12:30 PM EST — Artima Developer Buzz
- Yet Another C9 Feature Request — Channel 9
- Chef Umberto Bombana of the Ritz-Carlton hotel smells a huge ... — World Photos on Yahoo! News Photos
- Office Code Goes Gold — eWEEK Developer
- Sun Releases More Java Code For Open Source — internetnews.com Developer News
- Supreme Court Refuses 'Da Vinci Code' Case — WXII12.com - Entertainment News
- Our Favorite Food Reads with Recipes — Good Advice from Good Housekeeping
- Cast and filmmakers of the movie 'The Da Vinci Code' stand on ... — Entertainment Photos on Yahoo! News Photos
- Cingular: Having to dial area code prefix as of last week — FIXYOURTHINKING.COM
- Sun to offer Java code for free on the Internet — Technology & Media - International Herald Tribune
Latest news from Channel 9:
- Samba Team asks Novell to reconsider
- New Site and I don't know any HTML
- Once you go Mac
- Contractors taking a day off?
- BIG troubles with MSDN Subscription renewal. Any ideas?
- Why I won't give up on the Zune...
- Get away from the computer...
- WCF Ships, Doug Purdy Dances, and Don Box Sings
- Template for a Good Spec?
- Problem - Opening .eml files with System.Net.Mail