public class Foo
{
public int Count { get; set; }
}
public class FooHandler
{
private ConcurrentDictionary<string, Foo> FooHash = new ConcurrentDictionary<string, Foo>();
public IncrementFoo(string key)
{
FooHash[key].Count++;
}
}
我可以这样的方式更新Foo条目的属性吗?它是线程安全的(即在这种情况下获取或设置索引器原子)?