Results 1 to 4 of 4

Thread: COM RaiseEvents

  1. #1

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322

    COM RaiseEvents

    If I have several client object using a single server COM object using DCOM, and one client raise an event from the server, how can the other clients in other locations be informed as well (assuming all the other clients have an event handlers as well ?)
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    The COM object will raise an event in response to some activity. This event can be trapped by all the applications/clients using the object. You don't raise events from the clients to the COM object, and the event raised by the object is trappable by all clients.

    For e.g. application A and application B access a COM object C. C has been so programmed that it will accept a string from the client and display it in a message box. If the string is "honeybee" the object C should raise an event and notify any client that "honeybee" has been passed.

    Application A passes a string "cute" to object C. It is displayed in a message box. Application B passes another string "beautiful" and that too is displayed in the message box. Next Application A once again passes the string "honeybee". On recognizing this string, C will raise an event. This event can be handled in both the clients.

    Sorry, I forgot to add: This will work only if the object is the same. If both the clients are using different instances of the DCOM object, the above method may not work.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322
    The thing is with DCOM and MTS, COM are multithreaded objects.

    So if 5 clients are accessing 1 server at a time, A will trap an event but BCDE will not be informed that A has trapped an event as they do not share global data with different threads. Each thread has their own data but with the same variable name.

    I found the only way (I think) to do this is to provide synchronization via cross-thread marshalling (which is REAL slow) and the only way to implement this is NOT RaiseEvent but an older, but more powerful method of OLECallbacks.

    Ironically RaisingEvents is made to replaced OLECallbacks. RaisingEvent are easier to code and understand whereas OLECallbacks are harder to conceptualize BUT more powerful
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Here although it sounds like you already have everything under control and know what you are talking about.

    http://forums.vb-world.net/showthrea...221#post485221

Posting Permissions

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



Click Here to Expand Forum to Full Width