In my .NET application built with WPF and C# I call an async function using AsyncMethodCaller. In the callback I'd like to update some data in the GUI, but I'm not allowed to as this is owned by the main thread. How to I do it?
- Invoke an update on the main thread? How?
- Pass an object (e.g. ViewModel) as state to the callback and update data on this - which again is bound to the GUI?
- Some other way?
What's the common, recommended way of handling this?
The runtime error given is:
The calling thread cannot access this object because a different thread owns it.