+ Reply to Thread
Results 1 to 2 of 2

Thread: What is single-threaded apartment in COM?

  1. #1

    What is single-threaded apartment in COM?

    I am starting learning COM.

    I am stuck on this topic specifically 'apartments'. What is Single thread apartment or STA? Why does it needed?

    Please help me to clear my doubts.

  2. #2
    Single thread apartment allows you to run the COM object in single thread and forget about thread safety.

    It has following advantages:
    a. Simple to implement.
    b. No need to handle thread safety within object.
    c. Synchronization is taken care by the Windows Messaging Mechanism.

    a. Object should live in one thread.
    b. Each thread which hosts this type object should have Window's GetMessage/DispathMessage loop.
    c. You will need to marshal all pointers to object when you pass them between apartments.

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts