How about remove/acces, it's not only about adding? But reading items should be locked also.
There's a little problem by design: You're using an ObservableCollection
which is mostly used by the GUI.
I advise you not using the ObservableCollection<>
in other threads than the GUI thread. Controls who are 'listening' to the events will breakdown when triggered on other threads than the gui thread. When changing items in an ObservableCollection, it should be invoked on the Dispatcher. This way your collection is threadsafe. (because of not using it cross threading)
pseudo
public class MyControl: UserControl
{
private void MyMethodCalledFromAnOtherThread()
{
this.Dispatcher.Invoke(new Action(
{
// Change the collection...
myCol.Add("Hi there");
});
}