【发布时间】:2014-07-10 12:35:46
【问题描述】:
多线程应用程序,使用静态字典。用于处理请求,每个请求只能访问一条记录。
处理请求
- 读取记录
- 计算值的算法
- 更新记录。
在需要阻止特定记录的过程中。
static Dictionary<string, InstacneLevel> objlevel; -- Static variable
lock (key)
{
// need to lock required key
// read , Calclulate and update the value for that key
}
我没有找到任何线索,谁能帮帮我。
我可以使用 ConcurrentDictionary 吗??
【问题讨论】:
-
我不想锁定整个字典,只想锁定一条记录,因为其他线程可以处理其他记录..
标签: c# multithreading dictionary locking concurrentdictionary