简体   繁体   中英

When creating a Thread on a class called from an STAThread instance, what will the apartment state be?

I have project A and project B. Project B has a thread that does some work with Microsoft Outlook Interop. Project A is a GUI and is marked as STAThread on the main entry point.

If I call project b from within A, will the thread created in project B be STA or MTA?

I have an error "Retrieving the COM class factory for component with CLSID... An outgoing call cannot be made since the application is dispatching an input-sync call."

All threads default to MTAs, unless SetApartmentState is called before the thread is started.

If you think about it, the thread can't share the Single Threaded Apartment of an existing thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM