Question: Although there are many questions about COM and STA/MTA (e.g. [here](https://stackoverflow.com/questions/127188)), most of them talk about applications which have a UI. I, however, have the following setup:

* A console application, which is by default Multi-Threaded Apartment (Main() explicitly has the `[MTAThread]` attribute).
* The main thread spawns some worker threads.
* The main thread instantiates a single-threaded COM object.
* The main thread calls Console.ReadLine() until the user hits 'q', after which the application terminates.

A few questions:

* Numerous places mentions the [need of a message pump for COM objects](https://stackoverflow.com/questions/10654098/is-sta-message-loop-required-in-this-case). Do I need to manually create a message-pump for the main thread, or will the CLR create it for me on a new STA thread, as [this](https://stackoverflow.com/questions/6185610) question suggests?
* Just to make sure - assuming the CLR automagically creates the necessary plumbing, can I then use the COM object from any worker thread without the need of explicit synchronization?
* Which of the following is better in terms of performance:
	+ Let the CLR take care of the marshaling to and from the COM object.
	+ Explicitly instantiate the object on a separate STA thread, and have other thread communicate with it via e.g. a [`ConcurrentQueue`](http://msdn.microsoft.com/en-us/library/dd267265%28v=vs.110%29.aspx).

Answer: 
Yes, it is possible to create a *STA* COM object from an *MTA* thread.

In this case, *COM* (not *CLR*) will create an implicit STA apartment (a separate COM-owned thread) or re-use the existing one, created ealier. The COM object will be instantiated there, then a thread-safe proxy object (COM marshalling wrapper) will be created for it and returned to the MTA thread. All calls to the object made on the MTA thread will be marshalled by COM to that implicit STA apartment. 

This scenario is usually undesirable. It has a lot of shortcomings and may simply not work as expected, if COM is unable to marshal some interfaces of the object. Check [this question](https://stackoverflow.com/q/20308344/1768303) for more details. Besides, the message pump loop, run by the implicit STA apartment, pumps only a limited number of COM-specific messages. That may also affect the functionality of the COM. 

You may try it and it may work well for you. Or, you may run into some unpleasant issues like deadlocks, quite difficult to diagnose.

Here is a closely related question I just recently answered:

[StaTaskScheduler and STA thread message pumping](https://stackoverflow.com/q/21211998/1768303)

I'd personally prefer to manually control the logic of the inter-thread calls and thread affinity, with something like [`ThreadAffinityTaskScheduler`](https://github.com/noserati/tpl/blob/master/ThreadAffinityTaskScheduler.cs) proposed in my answer.

You may also want to read this: [INFO: Descriptions and Workings of OLE Threading Models](http://support.microsoft.com/kb/150777/EN-US), highly recommended.
> 
> Do I need to manually create a message-pump for the main thread,
> 
> 
> 

No. It is in the MTA therefore no message pump is needed.

> 
> or will the CLR create it for me on a new STA thread
> 
> 
> 

If COM creates the thread (because there is no STA in the process) then it also creates the message pump (and a hidden window: can be seen with the SPY++ and similar debugging tools).

> 
> COM object from any worker thread without the need of explicit synchronization
> 
> 
> 

Depends.

If the reference to the single threaded object (STO) was created in the MTA then COM will supply the appropriate proxy. This proxy is good for all threads in the MTA.

In any other case the reference will need to be marshalled to ensure it has the correct proxy.

> 
> is better in terms of performance
> 
> 
> 

The only answer to this is to test both and compare.

(Remember if you create the thread for the STA and then instantiate the object locally you need to do the message pumping. It is not clear to me that there is any CLR level lightweight message pump—including WinForms just for this certainly isn't.)

NB. The only in depth explanatory coverage of COM and the CLR is *.NET and COM: The Complete Interoperability Guide* by Adam Nathan (Sams, January 2002). But it is based on .NET 1.1 and now out of print (but there is a Kindle edition and is available via [Safari Books Online](http://www.safaribooksonline.com)). Even this book doesn't describe directly what you are trying to do. I would suggest some prototyping.