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.Refresh

Refreshes the properties presented by the MessageQueue to reflect the current state of the resource.

[Visual Basic]
Overridable Public Sub Refresh()
[C#]
public virtual void Refresh();
[C++]
public: virtual void Refresh();
[JScript]
public function Refresh();

Remarks

Refresh synchronizes the properties of a MessageQueue object with its associated Message Queuing backend resource. If any property, such as Label or Category, has changed on the backend since the time the MessageQueue instance was created, Refresh updates the MessageQueue with the new information.

The menu item, Refresh, associated with a message queue on the backend is not the same as the Refresh method. The menu item refreshes the view for the queue in the Message Queuing administrative tool. Refresh synchronizes the application-defined instance with the backend data, and is not merely associated with viewing the data.

Use Refresh when you are working with the static (in Visual Basic Shared) members that produce snapshot of the backend. For example, if you have called GetPublicQueues, GetPublicQueuesByCategory, GetPublicQueuesByLabel, GetPublicQueuesByMachine, or GetPrivateQueuesByMachine to retrieve a snapshot of queue data, it may be helpful to use Refresh to examine the property settings for a specific queue before manipulating the queue information.

Example [Visual Basic]

The following example illustrates how Refresh captures changes on a backend queue resource. You are prompted to change the label on a backend resource during execution. A message box indicates which resource was changed and what the new label is.

The example assumes that there is at least one public queue with the label "My Queue" on a computer on the network.

Import the System.Messaging and System.WinForms namespaces for this example.

[Visual Basic]

Private Sub RefreshLocalQueueInfo()
    'Define an array to hold the queues.
    Dim mqList() As MessageQueue
    'This is used in the for loop.
    Dim i As Integer
    'Get the public queues with the given label.
    mqList = MessageQueue.GetPublicQueuesByLabel("My Queue")
    '
    'Change a queue property using Message Queuing.
    MessageBox.Show("Use Message Queuing to change the label of any queue labeled My Queue")

    'Display the changed queues to the screen.
    For i = 0 To mqList.Length - 1
        'Sync with the current contents in Message Queuing.
        mqList(i).Refresh()
        'Display the changed label to the screen.
        If mqList(i).Label <> "My Queue" Then
MessageBox.Show(mqList(i).QueueName & ": label has changed to " & mqList(i).Label)
        End If
    Next
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | GetPublicQueues | GetPublicQueuesByCategory | GetPublicQueuesByLabel | GetPublicQueuesByMachine