Holy cow, I wrote a book!
A customer asked for guidance in software design:
Is there an issue with creating and using COM objects from a UI thread
which was initialized as STA?
I have heard that it is a best practice to create and use COM objects
on a background thread which is MTA.
I would like to have some more information as to why.
(I still have trouble with the phrase best practice,
especially when it is combined with the indefinite article:
a best practice.
It's like asking "Where is a tallest building?")
Good advice comes with a rationale so you can tell when it becomes
If you don't understanding why something should be done,
then you've fallen into the trap of cargo cult programming,
and you'll keep doing it even when it's no longer necessary
or even becomes deleterious.
In fact, you will find that if you try to follow this advice to the letter,
most shell objects will stop working,
shell objects tend to require an STA.
But in the absence of a rationale document or any other context,
it's unclear what the scope of the original advice was.
Maybe it makes sense in context, but right now it's just a statement
with no discussion or rationale.
When I asked the customer, "Can you provide the documents that
provided this recommendation?
Perhaps this 'best practice' makes sense in context.
Right now, it's just a bare recommendation with no discussion
The customer never wrote back.