Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. COM Apartment

COM Apartment

Scheduled Pinned Locked Moved ATL / WTL / STL
comquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KRISHNARAYALU
    wrote on last edited by
    #1

    Hi Guys, Reading about COM Threading since two days.. But still i Couldnt understand Exactly " What is an Apartment ". Kindly can any one explain in simple terms or show some source to understand more. Thanks, TV Krishna Rayalu

    L I 3 Replies Last reply
    0
    • K KRISHNARAYALU

      Hi Guys, Reading about COM Threading since two days.. But still i Couldnt understand Exactly " What is an Apartment ". Kindly can any one explain in simple terms or show some source to understand more. Thanks, TV Krishna Rayalu

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      A good description can be found on this MSDN page[^]. Basically it is whether the COM object can support multi-threading or not: crazy Microsoft terminology again.

      Use the best guess

      K 1 Reply Last reply
      0
      • L Lost User

        A good description can be found on this MSDN page[^]. Basically it is whether the COM object can support multi-threading or not: crazy Microsoft terminology again.

        Use the best guess

        K Offline
        K Offline
        KRISHNARAYALU
        wrote on last edited by
        #3

        Thanks Richard. That link is informative. i could able to understand STA and MTA, i got more discription on what STA and MTA do then what exactly Apartment is. Can you please define it in simple words. Thanks & Regards, TV Krishna Rayalu

        L 1 Reply Last reply
        0
        • K KRISHNARAYALU

          Thanks Richard. That link is informative. i could able to understand STA and MTA, i got more discription on what STA and MTA do then what exactly Apartment is. Can you please define it in simple words. Thanks & Regards, TV Krishna Rayalu

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          KRISHNARAYALU wrote:

          Can you please define it in simple words.

          Define what? The link I gave you uses fairly simple words, and explains exactly what the difference is. If you do not understand the difference between single-threaded and multi-threaded code, then you should avoid using COM.

          Use the best guess

          K 1 Reply Last reply
          0
          • L Lost User

            KRISHNARAYALU wrote:

            Can you please define it in simple words.

            Define what? The link I gave you uses fairly simple words, and explains exactly what the difference is. If you do not understand the difference between single-threaded and multi-threaded code, then you should avoid using COM.

            Use the best guess

            K Offline
            K Offline
            KRISHNARAYALU
            wrote on last edited by
            #5

            Richard, I may missed something vital in that article or Some basic in that concept. I will re read the article. Thanks for Support. Thanks & Regards, TV Krishna Rayalu

            1 Reply Last reply
            0
            • K KRISHNARAYALU

              Hi Guys, Reading about COM Threading since two days.. But still i Couldnt understand Exactly " What is an Apartment ". Kindly can any one explain in simple terms or show some source to understand more. Thanks, TV Krishna Rayalu

              I Offline
              I Offline
              imagiro
              wrote on last edited by
              #6

              First of all an apartment is an abstract concept, means, there is no physical thing behind. When a thread starts it decides in which apartment it wants to "live". It does so by calling CoInitialize or CoInitializeEx. An apartment is a kind of a convention how to handle things. A thread that initializes a single-threaded apartment states, that it does not allow any other threads to enter the same apartment. COM knows then, that all objects living in this apartment can be accessed only from this same thread and makes sure that these objects are used only from within this thread. A thread that initializes a multi-threaded apartment allows other threads. COM knows then, that multiple threads might access the objects in this apartment and relies on these objects to handle thread synchronization by themselfs. So how do other threads enter the same apartment? Simply also via CoInitializeEx. By requesting a multi-threaded apartment they will automatically resist in the same apartment as the other MTA threads since there can only be one MTA. So in the end each thread that initializes a STA creates its own apartment, while threads initializing MTA enter the one and only MTA. And the same is of course valid for all COM objects created from this thread.

              1 Reply Last reply
              0
              • K KRISHNARAYALU

                Hi Guys, Reading about COM Threading since two days.. But still i Couldnt understand Exactly " What is an Apartment ". Kindly can any one explain in simple terms or show some source to understand more. Thanks, TV Krishna Rayalu

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                http://docs.eiffel.com/sites/docs.eiffel.com/files/images/com-2.gif[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups