diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/SynchronizedObservableCollection.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/SynchronizedObservableCollection.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/SynchronizedObservableCollection.cs b/Software/Visual_Studio/Tango.Core/SynchronizedObservableCollection.cs new file mode 100644 index 000000000..f0a13b3c9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/SynchronizedObservableCollection.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; + +namespace Tango.Core +{ + public class SynchronizedObservableCollection<T> : ObservableCollection<T> + { + public SynchronizedObservableCollection() : base() + { + this.EnableCrossThreadOperations(); + } + + public SynchronizedObservableCollection(IEnumerable<T> collection) : base(collection) + { + + } + + protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) + { + if (ObservableEntityCollectionSettings._dispatcher != null) + { + ObservableEntityCollectionSettings._dispatcher.BeginInvoke(new Action(() => + { + base.OnCollectionChanged(e); + })); + } + else + { + base.OnCollectionChanged(e); + } + } + } +} |
