How to run something in the STA thread?

You can start STA Threads like so: Thread thread = new Thread(MethodWhichRequiresSTA); thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA thread.Start(); thread.Join(); //Wait for the thread to end The only problem is that your result object must be passed along somehow.. You can use a private field for that, or dive into passing along parameters into threads. … Read more

How can I make a background worker thread set to Single Thread Apartment?

This is not possible, BGW uses a threadpool thread. TP threads are always MTA, it cannot be changed. You will have to use a regular Thread, call SetApartmentState() before you start it. This thread also should pump a message loop, call Application.Run(). Maybe you ought to consider calling this code from the UI thread. Because … Read more

STAThread and multithreading

Apartment threading is a COM concept; if you’re not using COM, and none of the APIs you call use COM “under the covers”, then you don’t need to worry about apartments. If you do need to be aware of apartments, then the details can get a little complicated; a probably-oversimplified version is that COM objects … Read more