My problem is that my task is changing an observable collection that is data-bound to a UI element.
my task will report progress and this data will be updated to the ui via the observable collection
:
async private void getProductData()
{
await Task.Run(() => getTableDataFromDb(new Progress<string>(
data => _prc.Add(new ProductList() { Taxe = data })
), "List"));
}
private void getTableDataFromDb(IProgress<string> progress, string tabelName)
{
//simple exemple
for(var i =0; i < 100; i++)
progress.Report( "test"+i);
}
if i run this code i get this error:
This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.
How can i access the main thread to update this collections? Thanks