I am trying to figure this out, given the following code, does the Refresh() need to occur on the UI thread? It seems to work, and I am wondering if the CollectionViewSource is actually a thread-aware / safe object? It definately has properties and methods to support calling on the correct thread, just not sure if that is left up to the developer, or if this is accomplished within the object?
public CollectionViewSource UserList { get; private set; }
void setupCollections()
{
UserList = new CollectionViewSource();
UserList.Source = searchProvider.UserResults;
UserList.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
}
Is this Thread safe in Silverlight???
void RefreshUserList()
{
UserList.View.Refresh();
}
Or do you need to do something like this?
void RefreshUserList()
{
// Is This Required?
UserList.Dispatcher.BeginInvoke(() =>
{
UserList.View.Refresh();
});
// Or MVVM-light Method
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
UserList.View.Refresh();
});
}