none
Inter-Process Communications RRS feed

  • Question

  • Hi,

    I write an unmanaged C/C++ DLL that creates a single worker thread (once loaded at the first time) that simultaneously serves several users.

    Now, this thread should inform its user apps about several events and related info. Today it only informs the user app that caused the creation of this thread using a callback function, but now I need it to inform any user app that so requires. As my thread performs RT operations with an h/w, it should not be delayed, and therefore this type of communication must be fast.

    Does anybody has any suggetion?

    Thanks,
    Ofer.

    Ofer
    Sunday, June 7, 2009 2:07 PM

Answers

  • All GUI apps process windows messages so they are probably the easiest to use for the user apps.  You can use PostMessage to place a message in any window's message queue.  See RegisterWindowMessage for defining your own interprocess messages, and see FindWindow for obtaining the target HWNDs.  PostMessage is very fast for the sender so it should not delay your thread.

    PostMessage has only two DWORDs as data you can send.  If you need to send a lot more data you can consider using winsock or pipes, or you can supplement PostMessage with shared memory (see Creating Named Shared Memory).
    • Marked as answer by Ofer Elboher Sunday, June 7, 2009 6:30 PM
    Sunday, June 7, 2009 3:20 PM

All replies

  • Sunday, June 7, 2009 3:13 PM
  • All GUI apps process windows messages so they are probably the easiest to use for the user apps.  You can use PostMessage to place a message in any window's message queue.  See RegisterWindowMessage for defining your own interprocess messages, and see FindWindow for obtaining the target HWNDs.  PostMessage is very fast for the sender so it should not delay your thread.

    PostMessage has only two DWORDs as data you can send.  If you need to send a lot more data you can consider using winsock or pipes, or you can supplement PostMessage with shared memory (see Creating Named Shared Memory).
    • Marked as answer by Ofer Elboher Sunday, June 7, 2009 6:30 PM
    Sunday, June 7, 2009 3:20 PM
  • Thanks a lot for your prompt help, Scott.
    Ofer
    Sunday, June 7, 2009 6:30 PM