I'm not (intentionally) using threads in my C# app. In fact my main method has a [STAThread]
, which I thought meant I'd only be using one thread.
Why then, would I be getting this error message?
Cross-thread operation not valid: Control 'messageLog' accessed from a thread other than the thread it was created on.
There are a couple of types which can cause your code to run on different threads without any explicit call to System.Threading
. In particular FileSystemWatcher
and BackgroundWorker
come to mind. Are you using any of these types?
Also STAThread
in no way limits the ability of your process to spawn threads. It instead sets the COM apartment type of the initial application thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With