MessageQueue.GetMessageQueueEnumerator Método

Definição

Cria um objeto de enumerador para obter uma lista dinâmica de filas públicas na rede.

Sobrecargas

GetMessageQueueEnumerator()

Fornece a semântica de cursor somente de avanço para enumerar todas as filas públicas na rede.

GetMessageQueueEnumerator(MessageQueueCriteria)

Fornece a semântica de cursor somente de avanço para enumerar todas as filas públicas na rede que atendem aos critérios especificados.

GetMessageQueueEnumerator()

Fornece a semântica de cursor somente de avanço para enumerar todas as filas públicas na rede.

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

Retornos

Um MessageQueueEnumerator que fornece uma lista dinâmica de todas as filas de mensagens públicas na rede.

Exemplos

O exemplo de código a seguir itera em todas as filas de mensagens na rede e examina o caminho para cada fila. Por fim, ele exibe o número de filas públicas na rede.

#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

Comentários

Essa sobrecarga de GetMessageQueueEnumerator retorna uma enumeração de todas as filas públicas que estão na rede.

Como o cursor está associado a uma listagem dinâmica, a enumeração reflete qualquer modificação feita em uma lista de filas para filas excluídas ou adicionadas além da posição atual do cursor. Adições ou exclusão de filas localizadas antes da posição atual do cursor não são refletidas. Por exemplo, o enumerador pode acessar automaticamente uma fila acrescentada além da posição do cursor, mas não uma inserida antes dessa posição. No entanto, você pode redefinir a enumeração, movendo assim o cursor de volta para o início da lista, chamando Reset para o MessageQueueEnumerator.

Não há nenhuma ordenação definida de filas em uma rede. Um enumerador não os ordena, por exemplo, por computador, rótulo, status público ou privado ou qualquer outro critério acessível.

Se você quiser um instantâneo estático das filas na rede em vez de uma conexão dinâmica com elas, chame GetPublicQueues ou GetPrivateQueuesByMachine(String). Cada um desses dois métodos retorna uma matriz de MessageQueue objetos , que representam as filas no momento em que o método foi chamado.

A tabela a seguir mostra se esse método está disponível em vários modos de Grupo de Trabalho.

Modo de grupo de trabalho Disponível
Computador local Não
Nome do computador local e do formato direto Não
Computador remoto Não
Computador remoto e nome de formato direto Não

Confira também

Aplica-se a

GetMessageQueueEnumerator(MessageQueueCriteria)

Fornece a semântica de cursor somente de avanço para enumerar todas as filas públicas na rede que atendem aos critérios especificados.

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

Parâmetros

criteria
MessageQueueCriteria

Um MessageQueueCriteria que contém os critérios usados para filtrar as filas de mensagens disponíveis.

Retornos

Um MessageQueueEnumerator que fornece uma lista dinâmica de filas de mensagens públicas na rede que cumprem as restrições especificadas pelo parâmetro criteria.

Exemplos

O exemplo de código a seguir itera pelas filas de mensagens e exibe o caminho de cada fila que foi criada no último dia e que existe no computador "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

Comentários

Essa sobrecarga de GetMessageQueueEnumerator retorna uma listagem de todas as filas públicas na rede que atendem aos critérios definidos nos critérios do aplicativo. Você pode especificar os critérios a serem incluídos, por exemplo, hora de criação ou modificação da fila, nome do computador, rótulo, categoria ou qualquer combinação deles.

Como o cursor está associado a uma listagem dinâmica, a enumeração reflete qualquer modificação feita em uma fila que ocorre além da posição atual do cursor. As alterações nas filas localizadas antes da posição atual do cursor não são refletidas. Por exemplo, o enumerador pode acessar automaticamente uma fila acrescentada além da posição do cursor, mas não uma inserida antes dessa posição. No entanto, você pode redefinir a enumeração, movendo assim o cursor de volta para o início da lista, chamando Reset para o MessageQueueEnumerator.

Não há nenhuma ordenação definida de filas em uma rede. Um enumerador não os ordena, por exemplo, por computador, rótulo, status público ou privado ou qualquer outro critério acessível.

Se você quiser um instantâneo estático das filas na rede em vez de uma conexão dinâmica com elas, especifique critérios para GetPublicQueues ou chame GetPrivateQueuesByMachine(String). Cada um desses dois métodos retorna uma matriz de MessageQueue objetos , que representam as filas no momento em que o método foi chamado. Chamar GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String)ou GetPublicQueuesByMachine(String) fornece os mesmos resultados que chamar GetPublicQueues com os critérios de filtragem de Category, Labele MachineName, respectivamente.

A tabela a seguir mostra se esse método está disponível em vários modos de Grupo de Trabalho.

Modo de grupo de trabalho Disponível
Computador local Não
Nome do computador local e do formato direto Não
Computador remoto Não
Computador remoto e nome de formato direto Não

Confira também

Aplica-se a