Wednesday, April 25, 2012

Using data from C# DataReceived thread in a parent class (NO UI, can't Invoke)

I have a class that needs to have properties updated with data from the C# serial DataReceived event.

I'm not trying to update a UI, but the only references I find about using the results of the DataReceived event (which runs on a different thread) say to use .Invoke to get the data into a UI control. My class is not associated with a UI so .Invoke is not available.

When the handler tries to change a property in the class, I get the dreaded error: "The calling thread cannot access this object because a different thread owns it."

What is process for getting the results into the parent thread?

No comments:

Post a Comment