Im getting an error message when i try this:
Task.Factory
.StartNew(() => _model.GetItems(node).Select(n => n))
.ContinueWith(t =>
{
if (t.Result != null)
{
ObservableCollection<ItemValue> children = new ObservableCollection<ItemValue>(t.Result);
//fill some control
}
}, TaskScheduler.FromCurrentSynchronizationContext());
Error
Must create dependencysource on same thread as the dependencyobject
But if i try this code:
Task.Factory
.StartNew(() => _model.GetItems(node).Select(n => n))
.ContinueWith(t =>
{
if (t.Result != null)
{
ObservableCollection<ItemValue> children = _model.GetItems(node);
//fill some control
}
}, TaskScheduler.FromCurrentSynchronizationContext());
It's ok, no errors.
What am I doing wrong?
I want to fill collection in an other thread.