if interface need a picture it saves request in
ConcurrentDictionary<key, Delegate>
and when picture is on the disk read it and SavedDelegate?.Invoke(key, byte[])
.
But there is an error in this place:
private async void OnDelegateInvokeAsync(ImageItem item, byte[] body)
{
...
item.Image = new BitmapImage();
...
}
System.Exception: Calling Async synchronously, 'marshalled for a different thread' message (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))'
What is the best way to resolve this problem?
You should change the image in the UI thread:
Dispatcher.Invoke( ()=> { item.Image = new BitmapImage(); ... } );
User contributions licensed under CC BY-SA 3.0