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 tagged as STA must be run on an STAThread, and COM objects marked MTA must be run on an MTA thread. Using these rules, COM can optimize calls between these different objects, avoiding marshaling where it isn’t necessary.

Leave a Comment