I have a ViewModel which contains a QueryData method:
void QueryData() {
_dataService.GetData((item, error) =>
{
if(error != null)
return;
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
foreach(TimeData d in ((LineDetailData)item).Piecesproduced) {
Produced.Add(d);
}
}), DispatcherPriority.Send);
});
}
This method gets called each 10 seconds from a timer_Tick Event Handler. Then the Data is queried async and then the callback is executed. There the queried Data, should be inserted in an Observable Collection(not STA Thread -> begin Invoke). It correctly enter the callback, but the code inside Dispatcher.CurrentDispatcher.BeginInvoke isn't executed.
What am i doing wrong?