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. COM
  4. Help!! - "both" components

Help!! - "both" components

Scheduled Pinned Locked Moved COM
helptutorialquestion
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.
  • L Offline
    L Offline
    LasVegasGuy
    wrote on last edited by
    #1

    I have been running around in circles trying to find comprehensive guidelines and examples on how to write "both" components, the msdn site is totally#$#$# up. Can someone give me some guidelines and point me to some articels/samples? thanks a heap:) Man Learns from History that he never learns from History

    N 1 Reply Last reply
    0
    • L LasVegasGuy

      I have been running around in circles trying to find comprehensive guidelines and examples on how to write "both" components, the msdn site is totally#$#$# up. Can someone give me some guidelines and point me to some articels/samples? thanks a heap:) Man Learns from History that he never learns from History

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Could you be a little more descriptive in what you mean by "both" components. - Nick Parker
        My Blog

      L 1 Reply Last reply
      0
      • N Nick Parker

        Could you be a little more descriptive in what you mean by "both" components. - Nick Parker
          My Blog

        L Offline
        L Offline
        LasVegasGuy
        wrote on last edited by
        #3

        Trying to write an in-process component whose threading model will be "both". I want it to be instantiated in the same apartment as the client, irrespective of whether the client has entered an STA or MTA. If I understand right, the main criteria for writing this kind of component pertains to how I can perform callbacks to the client. thanks Man Learns from History that he never learns from History

        A 1 Reply Last reply
        0
        • L LasVegasGuy

          Trying to write an in-process component whose threading model will be "both". I want it to be instantiated in the same apartment as the client, irrespective of whether the client has entered an STA or MTA. If I understand right, the main criteria for writing this kind of component pertains to how I can perform callbacks to the client. thanks Man Learns from History that he never learns from History

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          That's right. If your component might use the client object on the thread other than STA (if the client is in STA), you'd have to do marshalling/unmarshalling of the client object "manually". Edward

          L 1 Reply Last reply
          0
          • A Anonymous

            That's right. If your component might use the client object on the thread other than STA (if the client is in STA), you'd have to do marshalling/unmarshalling of the client object "manually". Edward

            L Offline
            L Offline
            LasVegasGuy
            wrote on last edited by
            #5

            So would this work? When I decide I need to do a callback, I check the thread id of the current thread. If it matches the one that passed the callback pointer(which I would have stored somewhere), I make a direct call. If not, I call it via a proxy which I implement with custom marshalling. BTW, if I dont use callbacks in the component, can I go ahead and implement it as "both" without worrying about anything else? thanks!! Man Learns from History that he never learns from History

            A 1 Reply Last reply
            0
            • L LasVegasGuy

              So would this work? When I decide I need to do a callback, I check the thread id of the current thread. If it matches the one that passed the callback pointer(which I would have stored somewhere), I make a direct call. If not, I call it via a proxy which I implement with custom marshalling. BTW, if I dont use callbacks in the component, can I go ahead and implement it as "both" without worrying about anything else? thanks!! Man Learns from History that he never learns from History

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              I wouldn't bother with checking threadid, you rcomponent might be called from MTA. If your object pointer is not being passed directly to another thread (for instance one of object's methods created thread and from this thread you invoke one of the objects methods) you do not have to worry about this at all. And you are right, if you do not use other objects (callbacks or internally created com objects) in your component you don't have to worry about all this (of course synchronization must be taken care of). As for marshalling, in case it's necessary, I usually prefer using GIT (global interface table, works on NT sp3, Win95 with dcom): for instance when object gets created I'd register it in the GIT (IGlobalInterfaceTable::RegisterInterfaceInGlobal) and then all other threads that need to use the object would get the interface pointer from GIT (GetInterfaceFromGlobal) instead of using it directly, this way none the object itself can use any internal com objects (callbacks) safely. HTH, Edward

              A 1 Reply Last reply
              0
              • A Anonymous

                I wouldn't bother with checking threadid, you rcomponent might be called from MTA. If your object pointer is not being passed directly to another thread (for instance one of object's methods created thread and from this thread you invoke one of the objects methods) you do not have to worry about this at all. And you are right, if you do not use other objects (callbacks or internally created com objects) in your component you don't have to worry about all this (of course synchronization must be taken care of). As for marshalling, in case it's necessary, I usually prefer using GIT (global interface table, works on NT sp3, Win95 with dcom): for instance when object gets created I'd register it in the GIT (IGlobalInterfaceTable::RegisterInterfaceInGlobal) and then all other threads that need to use the object would get the interface pointer from GIT (GetInterfaceFromGlobal) instead of using it directly, this way none the object itself can use any internal com objects (callbacks) safely. HTH, Edward

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                So we do not need "custom" marshalling here, only "manual" invocation of the facilities already available. When the component gets the interface pointer to the callback object, it checks it into the GIT. When the client needs to be notified of something, the interface pointer is checked out from the GIT and the callback performed. thanks Steve

                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