Tuesday, December 20, 2011

Understanding and Using COM Threading Models

Understanding and Using COM Threading Models:

'via Blog this'


It may be helpful to remember a few key points about COM apartments:
  • An apartment is not a thread. The one-to-one relationship between threads and single-threaded apartments may lead you to believe that the two terms are interchangeable—they are not.
  • An object is not an apartment. Objects are created in apartments.
  • A particular instance of an object can belong to only one apartment.
  • An apartment's concurrency model, whether it is single-threaded or multi-threaded, cannot be changed after it is created.
  • A process can have zero or more single-threaded apartments—one for each thread that calls CoInitialize.
  • A process has one multi-threaded apartment or none at all—all threads that call CoInitializeEx with COINIT_MULTITHREADED share the same apartment.

No comments: