NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue Constructor

Initializes a new instance of the MessageQueue class.

Overload List

Initializes a new instance of the MessageQueue class. To use the object instantiated by the default constructor, the Path property must be set.

[Visual Basic] Overloads Public Sub New()
[C#] public MessageQueue();
[C++] public: MessageQueue();
[JScript] public function MessageQueue();

Initializes a new instance of the MessageQueue class that references the Message Queuing application resource specified by the path parameter.

[Visual Basic] Overloads Public Sub New(String)
[C#] public MessageQueue(String);
[C++] public: MessageQueue(String*);
[JScript] public function MessageQueue(String);

Initializes a new instance of the MessageQueue class that references the Message Queuing application resource specified by the path parameter, and has the specified queue access restriction.

[Visual Basic] Overloads Public Sub New(String, Boolean)
[C#] public MessageQueue(String, bool);
[C++] public: MessageQueue(String*, bool);
[JScript] public function MessageQueue(String, Boolean);

Example [Visual Basic]

The following example creates a new MessageQueue object and sends a message to the queue. The Path is set when the MessageQueue is created.

This example assumes that a QueueName (such as "myQueue") and a body (say, a text string) are passed into the procedure. It also assumes there is a Message Queuing computer named myComputer. The queue requires exclusive access by setting sharedModeDenyReceive to true.

Note   This example shows how to use one of the overloaded version of the MessageQueue constructor. For other examples that may be available, see the individual overload topics.

[Visual Basic]

Private Sub SendMessage(ByVal queueName As String, ByVal body As Object)
    'Define the queue path.
    Dim queuePath As String
    'Set the queue path to an existing queue, such as myComputer\myQueue.
    queuePath = "myComputer\" + queueName
    'define a new MessageQueue object.
    Dim mq As MessageQueue
    'Initialize the MessageQueue with exclusive access.
    mq = New MessageQueue(queuePath, True)

    'Send a message to the queue.
    mq.Send(body)
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace