c# event throws cross-thread error
Posted on 2014-07-23
I have created a com dll in c# that includes events. I have referenced it in my windows form application and
can call the exposed methods and get the results I expect without a problem. The issue is with events.
The dll runs a thread that checks a website for updated information .. it will raise an event when the
information has changed. I have included the event in my windows form and the event is raised correctly,
but when I try to update the textbox on the form I'm getting a cross thread exception:
protected void OnStateChanged(string eventData)
// this part works perfectly!
System.Diagnostics.Debug.WriteLine("eventdata: " + eventData);
// this line throws the cross-thread error.
textBox1.text = eventData;
how can I get around this? (I am using vs2012 and .net 4.5)