There is a WPF application in C #. One of the operations is the update of the ObservableCollection content in the view model class is quite long and at the same time constant (updated every few seconds). In order not to start, the UI decided to output to a separate thread using async - await - Task . Code :
private async void ResetAsync() { await Update(); } private Task Update() { return Task.Run(async ()=> { while (true) { // Do some... await Task.Delay(2000); } }); } However, there is a problem related to the fact (correct if not right) that the collection of the view model should be updated within the UI stream and not the one that I selected through Async - Await
This CollectionView type does not support changes to its SourceCollection from a stream other than the Dispatcher stream.
Now I need to use Dispatcher to return the result to the UI stream? Tell me how to do this?