Crashes on events trying to read data across threads
Error: An exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll but was not handled in user code
The cross-thread operation is invalid: The control simconnectstatus was obtained from a different thread than the thread on which it was created.
Using .net framework 4.7.2
Code Where it crashes:
I don't know what todo, i'm trying to send a structure data from my connect.cs file back to form1.cs using evnets, here i am trying to call the ondata event and it works just fine but at bottom where i define event args E as defsimvars withc is a class that contains a structure i wanna use i get this error message
2 Replies
simconnectstatus is a text label in winform, the error means it's trying to reach it from a diffenrent thread. I don't know how to get around that
only the ui thread is allowed to interact with the controls, so you have to marshal the request to that thread. something like this