Questions tagged «concurrent-collections»

4
在ConcurrentDictionary AddOrUpdate中为更新部分添加什么
我正在尝试使用Dictionary重新编写一些代码以使用ConcurrentDictionary。我已经查看了一些示例,但是在实现AddOrUpdate函数时仍然遇到困难。这是原始代码: 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; 我不知道要为更新部分添加什么: userDic.AddOrUpdate(authUser.UserId, a.Session.SessionID.ToString(), /*** what to add here? ***/); 任何指针将不胜感激。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.