MessageQueue.GetMessageQueueEnumerator Metoda

Definicja

Tworzy obiekt wyliczający dla dynamicznej listy kolejek publicznych w sieci.

Przeciążenia

GetMessageQueueEnumerator()

Udostępnia semantyka kursora tylko do przodu, aby wyliczać wszystkie kolejki publiczne w sieci.

GetMessageQueueEnumerator(MessageQueueCriteria)

Udostępnia semantyka kursora tylko do przodu, aby wyliczać wszystkie kolejki publiczne w sieci, które spełniają określone kryteria.

GetMessageQueueEnumerator()

Udostępnia semantyka kursora tylko do przodu, aby wyliczać wszystkie kolejki publiczne w sieci.

public:
 static System::Messaging::MessageQueueEnumerator ^ GetMessageQueueEnumerator();
public static System.Messaging.MessageQueueEnumerator GetMessageQueueEnumerator ();
static member GetMessageQueueEnumerator : unit -> System.Messaging.MessageQueueEnumerator
Public Shared Function GetMessageQueueEnumerator () As MessageQueueEnumerator

Zwraca

MessageQueueEnumerator

Element MessageQueueEnumerator zapewniający dynamiczną listę wszystkich publicznych kolejek komunikatów w sieci.

Przykłady

Poniższy przykład kodu iteruje wszystkie kolejki komunikatów w sieci i analizuje ścieżkę dla każdej kolejki. Na koniec wyświetla liczbę kolejek publicznych w sieci.

#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();
}
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;
        }
    }
}
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


        
        ' 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

End Class

Uwagi

To przeciążenie GetMessageQueueEnumerator zwraca wyliczenie wszystkich kolejek publicznych, które znajdują się w sieci.

Ponieważ kursor jest skojarzony z listą dynamiczną, wyliczenie odzwierciedla wszelkie modyfikacje wprowadzone na liście kolejek dla kolejek usuniętych lub dodanych poza bieżącą pozycją kursora. Dodanie lub usunięcie kolejek znajdujących się przed bieżącą pozycją kursora nie zostaną odzwierciedlone. Na przykład moduł wyliczający może automatycznie uzyskać dostęp do kolejki dołączonej poza położeniem kursora, ale nie jeden wstawiony przed tym położeniem. Można jednak zresetować wyliczenie, przenosząc kursor z powrotem na początek listy, wywołując polecenie Reset MessageQueueEnumerator.

W sieci nie ma zdefiniowanej kolejności kolejek. Moduł wyliczający nie porządkuje ich, na przykład według komputera, etykiety, stanu publicznego lub prywatnego ani innych kryteriów dostępnych.

Jeśli chcesz utworzyć statyczną migawkę kolejek w sieci, a nie dynamiczne połączenie z nimi, wywołaj polecenie GetPublicQueues lub GetPrivateQueuesByMachine(String). Każda z tych dwóch metod zwraca tablicę MessageQueue obiektów, które reprezentują kolejki w momencie wywołania metody.

W poniższej tabeli przedstawiono, czy ta metoda jest dostępna w różnych trybach grupy roboczej.

Tryb grupy roboczej Dostępne
Komputer lokalny Nie
Komputer lokalny i nazwa formatu bezpośredniego Nie
Komputer zdalny Nie
Nazwa komputera zdalnego i formatu bezpośredniego Nie

Zobacz też

Dotyczy

GetMessageQueueEnumerator(MessageQueueCriteria)

Udostępnia semantyka kursora tylko do przodu, aby wyliczać wszystkie kolejki publiczne w sieci, które spełniają określone kryteria.

public:
 static System::Messaging::MessageQueueEnumerator ^ GetMessageQueueEnumerator(System::Messaging::MessageQueueCriteria ^ criteria);
public static System.Messaging.MessageQueueEnumerator GetMessageQueueEnumerator (System.Messaging.MessageQueueCriteria criteria);
static member GetMessageQueueEnumerator : System.Messaging.MessageQueueCriteria -> System.Messaging.MessageQueueEnumerator
Public Shared Function GetMessageQueueEnumerator (criteria As MessageQueueCriteria) As MessageQueueEnumerator

Parametry

criteria
MessageQueueCriteria

Element MessageQueueCriteria zawierający kryteria używane do filtrowania dostępnych kolejek komunikatów.

Zwraca

MessageQueueEnumerator

Element MessageQueueEnumerator zawierający dynamiczną listę kolejek komunikatów publicznych w sieci, które spełniają ograniczenia określone przez criteria parametr .

Przykłady

Poniższy przykład kodu iteruje kolejki komunikatów i wyświetla ścieżkę każdej kolejki utworzonej w ciągu ostatniego dnia i istnieje na komputerze "MyComputer".

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // Iterates through message queues and displays the
   // path of each queue that was created in the last
   // day and that exists on the computer "MyComputer". 
   void ListPublicQueuesByCriteria()
   {
      UInt32 numberQueues = 0;
      
      // Specify the criteria to filter by.
      MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
      myCriteria->MachineName = "MyComputer";
      myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
      
      // Get a cursor into the queues on the network.
      MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator( myCriteria );
      
      // 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++;
      }

      
      // Handle no queues matching the criteria.
      if ( numberQueues == 0 )
      {
         Console::WriteLine( "No public queues match criteria." );
      }

      return;
   }

};

int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Output the count of Lowest priority messages.
   myNewQueue->ListPublicQueuesByCriteria();
   return 0;
}
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 that specify certain criteria.
        //**************************************************

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

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

        //**************************************************
        // Iterates through message queues and displays the
        // path of each queue that was created in the last
        // day and that exists on the computer "MyComputer".
        //**************************************************
        
        public void ListPublicQueuesByCriteria()
        {
            uint numberQueues = 0;
            
            // Specify the criteria to filter by.
            MessageQueueCriteria myCriteria = new
                MessageQueueCriteria();
            myCriteria.MachineName = "MyComputer";
            myCriteria.CreatedAfter = DateTime.Now.Subtract(new
                TimeSpan(1,0,0,0));

            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator =
                MessageQueue.GetMessageQueueEnumerator(myCriteria);

            // 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++;
            }

            // Handle no queues matching the criteria.
            if (numberQueues == 0)
            {
                Console.WriteLine("No public queues match criteria.");
            }

            return;
        }
    }
}
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 that specify certain criteria.
        

        Public Shared Sub Main()

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

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

            Return

        End Sub


        
        ' Iterates through message queues and displays the
        ' path of each queue that was created in the last
        ' day and that exists on the computer "MyComputer". 
        

        Public Sub ListPublicQueuesByCriteria()

            Dim numberQueues As Int32 = 0

            ' Specify the criteria to filter by.
            Dim myCriteria As New MessageQueueCriteria()
            myCriteria.MachineName = "MyComputer"
            myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
                TimeSpan(1, 0, 0, 0))


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

            ' 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

            ' Handle no queues matching the criteria.
            If numberQueues = 0 Then
                Console.WriteLine("No queues match the criteria.")
            End If

            Return

        End Sub

End Class

Uwagi

To przeciążenie GetMessageQueueEnumerator zwraca listę wszystkich kolejek publicznych w sieci, które spełniają kryteria zdefiniowane w kryteriach aplikacji. Można określić kryteria do uwzględnienia, na przykład czas tworzenia kolejki lub modyfikacji, nazwy komputera, etykiety, kategorii lub dowolnej kombinacji tych.

Ponieważ kursor jest skojarzony z listą dynamiczną, wyliczenie odzwierciedla wszelkie modyfikacje wprowadzone w kolejce, która występuje poza bieżącą pozycją kursora. Zmiany w kolejkach znajdujących się przed bieżącą pozycją kursora nie zostaną odzwierciedlone. Na przykład moduł wyliczający może automatycznie uzyskać dostęp do kolejki dołączonej poza położeniem kursora, ale nie jeden wstawiony przed tym położeniem. Można jednak zresetować wyliczenie, przenosząc kursor z powrotem na początek listy, wywołując polecenie Reset MessageQueueEnumerator.

W sieci nie ma zdefiniowanej kolejności kolejek. Moduł wyliczający nie porządkuje ich, na przykład według komputera, etykiety, stanu publicznego lub prywatnego ani innych kryteriów dostępnych.

Jeśli chcesz, aby statyczna migawka kolejek w sieci zamiast dynamicznego połączenia z nimi, określ kryteria lub GetPublicQueues wywołaj metodę GetPrivateQueuesByMachine(String). Każda z tych dwóch metod zwraca tablicę MessageQueue obiektów, które reprezentują kolejki w momencie wywołania metody. Wywołanie metody , lub zapewnia te same wyniki co wywołanie GetPublicQueues z kryteriami filtrowania odpowiednio Category, Labeli MachineName.GetPublicQueuesByMachine(String) GetPublicQueuesByLabel(String)GetPublicQueuesByCategory(Guid)

W poniższej tabeli przedstawiono, czy ta metoda jest dostępna w różnych trybach grupy roboczej.

Tryb grupy roboczej Dostępne
Komputer lokalny Nie
Komputer lokalny i nazwa formatu bezpośredniego Nie
Komputer zdalny Nie
Nazwa komputera zdalnego i formatu bezpośredniego Nie

Zobacz też

Dotyczy