angelsix / fasetto-word

The new chat application for Fasetto, completely open-source :)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question - Modify ObservableCollection from Non-UI-Thread

greycoding opened this issue · comments

First of all: the YouTube videos are really amazing! So much knowledge is transported.

However, I have a problem of understanding:
I get data from a server via a REST API. If I want to add this data to the ObservableCollection, I get the error message that this is only possible from the UI thread.

System.NotSupportedException: 'This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.'

So far I have made the following call for it:

App.Current.Dispatcher.Invoke ((Action) delegate ...);

But since I wanted to separate the ViewModels from the UI (as in Video 11), I don't know how to do it.
There doesn't seem to be any problems with the Fasetto.Word.Core project. In the corresponding SourceCode I also cannot find a (direct) call to the dispatcher. Is this because the filtering is also carried out on the UI thread? Or has something to do with the IOC (container)?How would you modify the ObservableCollections from a non-UI thread?