Click or drag to resize
ThreadedObservableCollectionT Class
Inheritance Hierarchy
SystemObject
  System.Collections.ObjectModelCollectionT
    System.Collections.ObjectModelObservableCollectionT
      DW.SharpToolsThreadedObservableCollectionT
        DW.SharpToolsEnhancedObservableCollectionT

Namespace: DW.SharpTools
Assembly: DW.SharpTools (in DW.SharpTools.dll) Version: 2.4.0.0 (2.4.0.0)
Syntax
C#
public class ThreadedObservableCollection<T> : ObservableCollection<T>

Type Parameters

T
The type of elements in the collection.

The ThreadedObservableCollectionT type exposes the following members.

Constructors
Methods
  NameDescription
Public methodAdd
Adds an object to the end of the DW.SharpTools.ThreadedObservableCollection{T}.
Public methodClear
Removes all elements from the DW.SharpTools.ThreadedObservableCollection{T}.
Public methodInsert
Inserts an element into the DW.SharpTools.ThreadedObservableCollection{T} at the specified index.
Public methodMove
Moves the item at the specified index to a new location in the DW.SharpTools.ThreadedObservableCollection{T}.
Public methodRemove
Removes the first occurrence of a specific object from the DW.SharpTools.ThreadedObservableCollection{T}.
Public methodRemoveAt
Removes the element at the specified index of the DW.SharpTools.ThreadedObservableCollection{T}.
Top
Properties
  NameDescription
Public propertyDispatcher
Gets or sets the dispatcher to be used for each item change in the collection. The default value is the CurrentDispatcher at the time the collection has been created.
Public propertyDispatcherAccess
Gets or sets the way how actions on the dispatcher has to be invoked. The default value is Invoke. This can be changes using the ThreadedObservableCollectionConfiguration.
Public propertyDispatcherPriority
Gets or sets the priority passed to the dispatcher invoke. The default value is Normal. This can be changes using the ThreadedObservableCollectionConfiguration.
Public propertyItem
Gets or sets the element at the specified index.
Top
Examples
C#
public class MainViewModel
{
    public MainViewModel()
    {
        Items = new ThreadedObservableCollection<string>();
    }

    public ThreadedObservableCollection<string> Items { get; private set; }

    private void Add()
    {
        new TaskFactory().StartNew(() => Items.Add(Guid.NewGuid().ToString()));
    }

    private void Remove()
    {
        if (!Items.Any())
            return;

        new TaskFactory().StartNew(() => Items.Remove(Items.First()));
    }
}
XAML
<DockPanel>
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Center">
        <Button Content="Add Multithreaded" Command="{Binding AddCommand}" />
        <Button Content="Remove Multithreaded" Command="{Binding RemoveCommand}" />
    </StackPanel>

    <ListBox ItemsSource="{Binding Items}" />
</DockPanel>
See Also