Files
@ f2c2ba4ef3d4
Branch filter:
Location: seniordesign-ui/GMap.NET.WindowsForms/GMap.NET.ObjectModel/ObservableCollectionThreadSafe.cs - annotation
f2c2ba4ef3d4
2.0 KiB
text/x-csharp
Removed unneeded code and verified use of functions. project is essentially
complete except for some live testing and cache testing/experiments
complete except for some live testing and cache testing/experiments
65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 65c134a3d619 | 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
}
}
}
}
}
}
|