I am trying to rewrite code using a dictionary to use ConcurrentDictionary. I looked at some examples, but I still can not implement the AddOrUpdate function. This is the source code:
dynamic a = HttpContext; Dictionary<int, string> userDic = this.HttpContext.Application["UserSessionList"] as Dictionary<int, String>; if (userDic != null) { if (useDic.ContainsKey(authUser.UserId)) { userDic.Remove(authUser.UserId); } } else { userDic = new Dictionary<int,string>(); } userDic.Add(authUser.UserId, a.Session.SessionID.ToString()); this.HttpContext.Application["UserDic"] = userDic;
I do not know what to add for the update part:
userDic.AddOrUpdate(authUser.UserId, a.Session.SessionID.ToString(), );
Any pointers would be appreciated.
c # concurrent-collections
user438331 Aug 11 '11 at 15:49 2011-08-11 15:49
source share