title: ObservableCollection not thread-safe even in .NET 4.5?
body: <p>I am banging my head against the virtual wall for days now.
  The BindingOperations.EnableSynchronization method seems to work only partial in .NET 4.5.</p>
  
  <p>I wrote a test that fails sometimes:</p>
  
  <pre><code>        object blah = new object();
  
          Application app = Application.Current == null ? new Application() : Application.Current;
          SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
          ObservableCollection&lt;ThreadSafeObservableTestObject&gt; collection = null;
          collection = new ObservableCollection&lt;ThreadSafeObservableTestObject&gt;();
  
          BindingOperations.EnableCollectionSynchronization(collection, blah);
  
          CollectionTestWindow w = new CollectionTestWindow();
  
          Task.Factory.StartNew(() =&gt;
          {
              Thread.Sleep(2000);
              w.TestCollection = collection;
              collection.CollectionChanged += collection_CollectionChanged;
              collection.Add(new ThreadSafeObservableTestObject() { ID = 1, Name = "Sandra Bullock" });
              collection.Add(new ThreadSafeObservableTestObject() { ID = 2, Name = "Jennifer Aniston" });
              collection.Add(new ThreadSafeObservableTestObject() { ID = 3, Name = "Jennifer Lopez" });
              collection.Add(new ThreadSafeObservableTestObject() { ID = 4, Name = "Angelina Jolie" });
              collection.Add(new ThreadSafeObservableTestObject() { ID = 5, Name = "Mary Elizabeth Mastrantonio" });
              Thread.Sleep(5000);
              System.Windows.Application.Current.Dispatcher.Invoke(() =&gt; w.Close());
              System.Windows.Application.Current.Dispatcher.Invoke(() =&gt; Application.Current.Shutdown());
          });
          app.Run(w);
  </code></pre>
  
  <p>The TestCollectionWindow looks like this:</p>
  
  <pre><code>    &lt;ItemsControl ItemsSource="{Binding TestCollection}" Name="list"&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;TextBlock Text="{Binding Name}" /&gt;
                      &lt;TextBlock Text="{Binding ID}" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>So nothing magic here. But the result is almost every time that some entries are twice in the UI - the same objects!
  The result window looks like this then:</p>
  
  <blockquote>
    <p>Sandra Bullock 1<br>
    Jennifer Aniston 2<br>
    Jennifer Lopez 3<br>
    Angelina Jolie 4<br>
    Mary Elizabeth Mastrantonio 5<br>
    Jennifer Aniston 2  </p>
  </blockquote>
  
  <p>As you can clearly see Jennifer Aniston is listed twice. This can be reproduced easily. 
  Is this a general problem or is there anything wrong with this test, such as a flawed application instantiation?</p>
  
  <p>Thank you in advance!</p>