Communication between Multiple Threads in a WPF Application
- by Robert
I'm creating a WPF application that uses a custom object to populate all the controls. The constructor of that object is initiated by an EventHandler that waits for an API. The problem I'm having is when I try to access any information from that object using a button for example, it returns an error saying "The calling thread cannot access this object because a different thread owns it". I'm assuming this is because the EventHandler creates a new thread which doesn't allow the Main Thread to have access to it. Any ideas on how to get around this?
I'm basically having the error "The calling thread cannot access this object because a different thread owns it" when trying to get or set a CollectionViewSource.