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. ATL - Collections - shared data

ATL - Collections - shared data

Scheduled Pinned Locked Moved COM
c++comdocker
2 Posts 2 Posters 2 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
    Lost User
    wrote on last edited by
    #1

    Hi - New to COM / ATL, just getting to grips with this stuff. Could anyone tell me if its possible to have a collection which is populated from c++ client code and viewed in say a VB client app. The client code would receive messages from a remote system and add them to a collection - I can get this bit working - however what I now need is to be able to view the same collection via a VB client. This client would be periodically kicked via connection point to inform it that a message had arrived. How I envisage this to work is as follows: (NT Service) * One NT service receiving messages via DCOM. * Creates a collection item. * Adds it to the collection. * Kicks the VB app via connection point. (DLL) One DLL which holds the collection class. (VB Client) * VB app wakes up * VB app requests collection items via DLL. * Messages are displayed in the VB app. (NT Service) Mean while the NT service continues to manipulate the collection and informs the VB app. I thought that if I make the collection container a singleton then only one instance would be created and the NT service and vb app would see the same collection. This does not seem to be the case. Could anyone explain how I create a shared collection between my NT service and the vb app via a DLL. Many thanks for any advice offered!

    T 1 Reply Last reply
    0
    • L Lost User

      Hi - New to COM / ATL, just getting to grips with this stuff. Could anyone tell me if its possible to have a collection which is populated from c++ client code and viewed in say a VB client app. The client code would receive messages from a remote system and add them to a collection - I can get this bit working - however what I now need is to be able to view the same collection via a VB client. This client would be periodically kicked via connection point to inform it that a message had arrived. How I envisage this to work is as follows: (NT Service) * One NT service receiving messages via DCOM. * Creates a collection item. * Adds it to the collection. * Kicks the VB app via connection point. (DLL) One DLL which holds the collection class. (VB Client) * VB app wakes up * VB app requests collection items via DLL. * Messages are displayed in the VB app. (NT Service) Mean while the NT service continues to manipulate the collection and informs the VB app. I thought that if I make the collection container a singleton then only one instance would be created and the NT service and vb app would see the same collection. This does not seem to be the case. Could anyone explain how I create a shared collection between my NT service and the vb app via a DLL. Many thanks for any advice offered!

      T Offline
      T Offline
      Todd Wilson
      wrote on last edited by
      #2

      From my recent experiance, you can't properly impliment a singleton in a DLL; you have to use an .EXE. It's not all that hard - make a new ATL project with EXE (not server). Create a new ATL Simple Com object (MyCollection). Make it a singleton with the DECLARE_CLASSFACTORY_SINGLETON(CMyCollection) macro. Modify your STDAFX.H generated file and change _ATL_APARTMENT_THREADED to _ATL_FREE_THREADED. You're good to go. Register it. Import your generated .TLB to make the smart pointers and whatever. I suggest using something like this: MyServerApp::IMySingletonPtr iSingle("MyServerApp.MySingleton") for each use, since it's very possible for the user to kill the process. Word of warning: once the last usage of your singleton (addref/release) is released, if there is no activity for 5 seconds, then it will be destroyed. If this is a problem, then either use connection points or some other refernce mechanisim.

      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