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 particularFileSystemWatcherandBackgroundWorkercome to mind. Are you using any of these types?Also
STAThreadin no way limits the ability of your process to spawn threads. It instead sets the COM apartment type of the initial application thread.