private void Favorites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Action action = () =>
{
if (e.NewItems != null)
{
//lock (controller.Favorites)
//{
//cast really isnt needed right now.
var newItems = e.NewItems.Cast<Favorites.Favorite>().ToArray();
foreach (var ni in newItems)
{
lstFavorites.Items.Add(ni);
}
//}
}
if (e.OldItems != null)
{
//lock (controller.Favorites)
//{
var oldItems = e.OldItems.Cast<Favorites.Favorite>().ToArray();
foreach (var oi in oldItems)
{
lstFavorites.Items.Remove(oi);
}
//}
}
};
if (InvokeRequired)
Invoke(action);
else
action();
}