Freigeben über


MessageQueueEnumerator-Klasse

Stellt einen Vorwärtscursor zum Durchlaufen der Meldungen in einer Meldungswarteschlange bereit.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

Syntax

'Declaration
Public Class MessageQueueEnumerator
    Inherits MarshalByRefObject
    Implements IEnumerator, IDisposable
'Usage
Dim instance As MessageQueueEnumerator
public class MessageQueueEnumerator : MarshalByRefObject, IEnumerator, IDisposable
public ref class MessageQueueEnumerator : public MarshalByRefObject, IEnumerator, IDisposable
public class MessageQueueEnumerator extends MarshalByRefObject implements IEnumerator, IDisposable
public class MessageQueueEnumerator extends MarshalByRefObject implements IEnumerator, IDisposable

Hinweise

Der MessageQueueEnumerator ermöglicht die dynamische Interaktion mit Warteschlangen im Netzwerk. Die von der MessageQueue-Klasse bereitgestellten Methoden geben entweder einen MessageQueueEnumerator zurück, der eine dynamische Liste von Warteschlangen enthält, oder ein Array mit einer Kopie der Warteschlangenauflistung zum Zeitpunkt des Methodenaufrufs (Snapshot).

Für Warteschlangen in einem Netzwerk ist keine Reihenfolge festgelegt. Sie sind nicht nach Kriterien wie Computer, Bezeichnung, Status (öffentlich/privat) oder anderen für Benutzer zugänglichen Kriterien geordnet. Ein MessageQueueEnumerator ist ein Cursor, der beim Initialisieren auf den Anfang einer dynamischen Liste gesetzt wird. Durch einen Aufruf von MoveNext setzen Sie den Cursor auf die erste Warteschlange in der Enumeration. Nach der Initialisierung des Enumerators können Sie mit MoveNext die einzelnen Warteschlangen durchlaufen.

Es ist nicht möglich, einen MessageQueueEnumerator auf eine Meldung vor der aktuellen Position zu setzen. Der Cursor ermöglicht ausschließlich das Setzen auf die nachfolgenden Warteschlangen in der Enumeration. Sie können jedoch Reset aufrufen, um den Cursor zurück auf den Anfang der Liste zu setzen. Da ein Enumerator dynamisch ist, kann über ihn auf eine Warteschlange zugegriffen werden, die hinter der aktuellen Position des Cursors angefügt wurde. Auf eine Warteschlange, die vor der aktuellen Cursorposition eingefügt wurde, kann nicht ohne einen vorherigen Aufruf von Reset zugegriffen werden.

Beispiel

Im folgenden Codebeispiel werden alle Meldungswarteschlangen im Netzwerk durchlaufen und die Pfade für alle Warteschlangen überprüft. Zum Abschluss wird die Anzahl der öffentlichen Warteschlangen im Netzwerk angezeigt.

Imports System
Imports System.Messaging



Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '        
        ' This example uses a cursor to step through the
        ' message queues and list the public queues on the
        ' network.
        

        Public Shared Sub Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New MyNewQueue()

            ' Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueues()

            Return

        End Sub 'Main


        
        ' Iterates through message queues and examines the
        ' path for each queue. Also displays the number of
        ' public queues on the network.
        

        Public Sub ListPublicQueues()

            ' Holds the count of private queues.
            Dim numberQueues As Int32 = 0

            ' Get a cursor into the queues on the network.
            Dim myQueueEnumerator As MessageQueueEnumerator = _
                MessageQueue.GetMessageQueueEnumerator()

            ' Move to the next queue and read its path.
            While myQueueEnumerator.MoveNext()
                ' Increase the count if the priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path)
                numberQueues += 1
            End While

            ' Display final count.
            Console.WriteLine(("Number of public queues: " + _
                numberQueues.ToString()))

            Return

        End Sub 'ListPublicQueues

End Class 'MyNewQueue
using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //       
        // This example uses a cursor to step through the
        // message queues and list the public queues on the
        // network.
        //**************************************************

        public static void Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueues();
                        
            return;
        }


        //**************************************************
        // Iterates through message queues and examines the
        // path for each queue. Also displays the number of
        // public queues on the network.
        //**************************************************
        
        public void ListPublicQueues()
        {
            // Holds the count of private queues.
            uint numberQueues = 0;
    
            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator = 
                MessageQueue.GetMessageQueueEnumerator();

            // Move to the next queue and read its path.
            while(myQueueEnumerator.MoveNext())
            {
                // Increase the count if priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path);
                numberQueues++;
            }

            // Display final count.
            Console.WriteLine("Number of public queues: " + 
                numberQueues.ToString());
            
            return;
        }
    }
}
#using <System.dll>
#using <System.Messaging.dll>

using namespace System;
using namespace System::Messaging;

//**************************************************
// Iterates through message queues and examines the
// path for each queue. Also displays the number of
// public queues on the network.
//**************************************************
void ListPublicQueues()
{
   
   // Holds the count of private queues.
   int numberQueues = 0;
   
   // Get a cursor into the queues on the network.
   MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator();
   
   // Move to the next queue and read its path.
   while ( myQueueEnumerator->MoveNext() )
   {
      
      // Increase the count if priority is Lowest.
      Console::WriteLine( myQueueEnumerator->Current->Path );
      numberQueues++;
   }

   
   // Display final count.
   Console::WriteLine( "Number of public queues: {0}", numberQueues );
   return;
}


//**************************************************
// Provides an entry point into the application.
//   
// This example uses a cursor to step through the
// message queues and list the public queues on the
// network.
//**************************************************
int main()
{
   
   // Output the count of Lowest priority messages.
   ListPublicQueues();
}
package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example uses a cursor to step through the
    // message queues and list the public queues on the
    // network.
    //**************************************************
    public static void main(String[] args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Output the count of Lowest priority messages.
        myNewQueue.ListPublicQueues();
        return;
    } //main

    //**************************************************
    // Iterates through message queues and examines the
    // path for each queue. Also displays the number of
    // public queues on the network.
    //**************************************************
    public void ListPublicQueues()
    {
        // Holds the count of private queues.
        long numberQueues = 0;        
        
        // Get a cursor into the queues on the network.
        MessageQueueEnumerator myQueueEnumerator =
            MessageQueue.GetMessageQueueEnumerator();
        // Move to the next queue and read its path.
        while (myQueueEnumerator.MoveNext()) {
            // Increase the count if priority is Lowest.
            Console.WriteLine(myQueueEnumerator.get_Current().get_Path());
            numberQueues++;
        }
        // Display final count.
        Console.WriteLine("Number of public queues: "
            + ((Int32)numberQueues).ToString());
        return;
    } //ListPublicQueues
} //MyNewQueue

Vererbungshierarchie

System.Object
   System.MarshalByRefObject
    System.Messaging.MessageQueueEnumerator

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MessageQueueEnumerator-Member
System.Messaging-Namespace
MessageQueue-Klasse
MessageQueue.GetMessageQueueEnumerator