GMap.NET.WindowsForms/GMap.NET.ObjectModel/ObservableCollectionThreadSafe.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
namespace GMap.NET.ObjectModel
{
public class ObservableCollectionThreadSafe<T> : ObservableCollection<T>
{
NotifyCollectionChangedEventHandler collectionChanged;
public override event NotifyCollectionChangedEventHandler CollectionChanged
{
add
{
collectionChanged += value;
}
remove
{
collectionChanged -= value;
}
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
// Be nice - use BlockReentrancy like MSDN said
using(BlockReentrancy())
{
if(collectionChanged != null)
{
Delegate[] delegates = collectionChanged.GetInvocationList();
// Walk thru invocation list
foreach(NotifyCollectionChangedEventHandler handler in delegates)
{
#if !PocketPC
System.Windows.Forms.Control dispatcherObject = handler.Target as System.Windows.Forms.Control;
// If the subscriber is a DispatcherObject and different thread
if(dispatcherObject != null && dispatcherObject.InvokeRequired)
{
// Invoke handler in the target dispatcher's thread
dispatcherObject.Invoke(handler, this, e);
}
else // Execute handler as is
{
collectionChanged(this, e);
}
#else
// If the subscriber is a DispatcherObject and different thread
if(handler != null)
{
// Invoke handler in the target dispatcher's thread
handler.Invoke(handler, e);
}
else // Execute handler as is
{
collectionChanged(this, e);
}
#endif
}
}
}
}
后面还有 2 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
