MessageQueue.GetMessageQueueEnumerator Metodo

Definizione

Crea un oggetto enumeratore per un elenco dinamico delle code pubbliche presenti sulla rete.

Overload

GetMessageQueueEnumerator()

Fornisce la semantica del cursore forward-only per enumerare tutte le code pubbliche sulla rete.

GetMessageQueueEnumerator(MessageQueueCriteria)

Fornisce la semantica del cursore forward-only per enumerare tutte le code pubbliche sulla rete che soddisfano i criteri specificati.

GetMessageQueueEnumerator()

Fornisce la semantica del cursore forward-only per enumerare tutte le code pubbliche sulla rete.

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

Restituisce

Oggetto MessageQueueEnumerator che fornisce un elenco dinamico di tutte le code di messaggi pubbliche sulla rete.

Esempio

Nell'esempio di codice seguente viene eseguita l'iterazione di tutte le code di messaggi nella rete ed esamina il percorso per ogni coda. Viene infine visualizzato il numero di code pubbliche nella rete.

#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

Commenti

Questo overload di GetMessageQueueEnumerator restituisce un'enumerazione di tutte le code pubbliche presenti nella rete.

Poiché il cursore è associato a un elenco dinamico, l'enumerazione riflette tutte le modifiche apportate a un elenco di code per le code eliminate o aggiunte oltre la posizione corrente del cursore. Aggiunte o eliminazione di code posizionate prima che la posizione corrente del cursore non venga riflessa. Ad esempio, l'enumeratore può accedere automaticamente a una coda aggiunta oltre la posizione del cursore, ma non a quella inserita prima di tale posizione. Tuttavia, è possibile reimpostare l'enumerazione, spostando il cursore all'inizio dell'elenco, chiamando Reset per .MessageQueueEnumerator

Non esiste un ordinamento definito di code in una rete. Un enumeratore non li ordina, ad esempio per computer, etichetta, stato pubblico o privato o per altri criteri accessibili.

Se si desidera uno snapshot statico delle code nella rete anziché una connessione dinamica, chiamare GetPublicQueues o GetPrivateQueuesByMachine(String). Ognuno di questi due metodi restituisce una matrice di MessageQueue oggetti, che rappresentano le code al momento della chiamata del metodo.

Nella tabella seguente viene illustrato se questo metodo è disponibile in varie modalità gruppo di lavoro.

Modalità gruppo di lavoro Disponibile
Computer locale No
Computer locale e nome del formato diretto No
Computer remoto No
Nome del formato diretto e del computer remoto No

Vedi anche

Si applica a

GetMessageQueueEnumerator(MessageQueueCriteria)

Fornisce la semantica del cursore forward-only per enumerare tutte le code pubbliche sulla rete che soddisfano i criteri specificati.

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

Parametri

criteria
MessageQueueCriteria

Oggetto MessageQueueCriteria contenente i criteri utilizzati per filtrare le code di messaggi disponibili.

Restituisce

Oggetto MessageQueueEnumerator che fornisce un elenco dinamico delle code di messaggi pubbliche sulla rete che soddisfano le restrizioni specificate dal parametro criteria.

Esempio

Nell'esempio di codice seguente viene eseguito l'iterazione delle code di messaggi e viene visualizzato il percorso di ogni coda creata nell'ultimo giorno e presente nel computer "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

Commenti

Questo overload di GetMessageQueueEnumerator restituisce un elenco di tutte le code pubbliche nella rete che soddisfano i criteri definiti nei criteri dell'applicazione. È possibile specificare i criteri da includere, ad esempio, l'ora di creazione o modifica della coda, il nome del computer, l'etichetta, la categoria o qualsiasi combinazione di queste.

Poiché il cursore è associato a un elenco dinamico, l'enumerazione riflette tutte le modifiche apportate a una coda che si verifica oltre la posizione corrente del cursore. Le modifiche apportate alle code che si trovano prima della posizione corrente del cursore non vengono riflesse. Ad esempio, l'enumeratore può accedere automaticamente a una coda aggiunta oltre la posizione del cursore, ma non a quella inserita prima di tale posizione. Tuttavia, è possibile reimpostare l'enumerazione, spostando il cursore all'inizio dell'elenco, chiamando Reset per .MessageQueueEnumerator

Non esiste un ordinamento definito di code in una rete. Un enumeratore non li ordina, ad esempio per computer, etichetta, stato pubblico o privato o per altri criteri accessibili.

Se si vuole uno snapshot statico delle code nella rete anziché una connessione dinamica, specificare i criteri per GetPublicQueues o chiamare GetPrivateQueuesByMachine(String). Ognuno di questi due metodi restituisce una matrice di MessageQueue oggetti, che rappresentano le code al momento della chiamata del metodo. La chiamata GetPublicQueuesByCategory(Guid)a , GetPublicQueuesByLabel(String)o GetPublicQueuesByMachine(String) fornisce gli stessi risultati della chiamata GetPublicQueues con i criteri di filtro rispettivamente di Category, Labele MachineName.

Nella tabella seguente viene illustrato se questo metodo è disponibile in varie modalità gruppo di lavoro.

Modalità gruppo di lavoro Disponibile
Computer locale No
Computer locale e nome del formato diretto No
Computer remoto No
Nome del formato diretto e del computer remoto No

Vedi anche

Si applica a