I'm write UWP app with MVVM, not Xamarin. This code throw System.Runtime.InteropServices.COMException exception on Tenders.Clear();
public ObservableCollection<Tender> Tenders { get; set; }
private void GetTendersFromCache()
{
Tenders = new ObservableCollection<Tender>();
var cache = BlobCache.LocalMachine.GetAndFetchLatest("TendersResponse",
async () => await _dataService.GetTenders());
cache.Subscribe(cachedTenders =>
{
Tenders.Clear();
foreach (var tender in cachedTenders)
{
Tenders.Add(tender);
}
});
}
How can I update collection Tenders correctly?
Put this code into Dispatcher.InvokeAsync not help.
Exception info
An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.ni.dll but was not handled in user code Additional information: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
User contributions licensed under CC BY-SA 3.0