【发布时间】:2011-06-06 02:58:45
【问题描述】:
有人可以向我解释BlockReentrancy 方法在ObservableCollection<T> 中的用途吗?
MSDN 显示以下示例:
//The typical usage is to wrap an OnCollectionChanged call within a using scope, as in the following example:
using (BlockReentrancy())
{
// OnCollectionChanged call
}
但这似乎并没有说明我的目的是什么。有人愿意解释吗?
【问题讨论】:
-
发音
BlockReëntrancy -
除了公认的答案之外,值得一提的是,在多线程用例中,当集合更新如此频繁以至于干扰
OnCollectionChanged处理时,也需要using (BlockReentrancy()) {}。只需一个 XAML 绑定并且自定义代码中没有任何其他显式订阅者,这可能会发生。
标签: c# .net events collections observablecollection