Discuss this help topic in MsgConnect Forum

Messenger class

Properties     Methods     Events     See also    


Messenger is the main class of MsgConnect. It is used to send and receive messages in the thread.

Description

    Messenger is the core of MsgConnect. It offers a set of methods to send and receive messages. It links queues and transports together, thus creating a solid system. Messenger is built in the way that it can handle as many message queues as you wish (much like messaging system in Windows does).

    Create an instance of Messenger class using it's Create method. When you don't need the messenger anymore, delete it (where applicable) using Destroy method.

    (optional) Initialize the message using one of the following methods:

    Sending a message is done via one of the following methods:

  • PostMessage - use it to send a one-way message when no result is required;
  • SendMessage - use it to send a message and wait for result;
  • SendMessageTimeout - use it to send a message and wait for result no more than specified time;
  • SendMessageCallback - use it to send a message and be notified when result arrives;
  • SendMessageTimeoutCallback - use it to send a message and be notified when result arrives, message delivery time expires or error happens

    If you've created a Queue object, messages are dispatched via Queue and Handler objects. All you will need is to call DispatchMessages method periodically to let messenger call proper event handlers.
    There is another option to receive messages -- via GetMessage and PeekMessage methods. If you use these methods to get the message from the message queue, you will need to call MessageProcessed method when the message is processed, so that messenger can send a result and dispose of message data.

Properties

Methods

Events

Discuss this help topic in MsgConnect Forum