Share via


MessageQueue.GetMessageQueueEnumerator Metoda

Definice

Vytvoří objekt enumerátoru pro dynamický výpis veřejných front v síti.

Přetížení

GetMessageQueueEnumerator()

Poskytuje sémantiku kurzoru pouze vpřed pro výčet přes všechny veřejné fronty v síti.

GetMessageQueueEnumerator(MessageQueueCriteria)

Poskytuje dopřednou sémantiku kurzoru pro výčet všech veřejných front v síti, které splňují zadaná kritéria.

GetMessageQueueEnumerator()

Poskytuje sémantiku kurzoru pouze vpřed pro výčet přes všechny veřejné fronty v síti.

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

Návraty

A MessageQueueEnumerator , který poskytuje dynamický výpis všech veřejných front zpráv v síti.

Příklady

Následující příklad kódu iteruje všechny fronty zpráv v síti a prozkoumá cestu pro každou frontu. Nakonec zobrazí počet veřejných front v síti.

#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

Poznámky

Toto přetížení GetMessageQueueEnumerator vrátí výčet všech veřejných front, které jsou v síti.

Vzhledem k tomu, že kurzor je přidružen k dynamickému výpisu, výčet odráží všechny změny provedené v seznamu front pro fronty odstraněné nebo přidané za aktuální pozici kurzoru. Přidání nebo odstranění front umístěných před aktuální pozicí kurzoru se neprojeví. Enumerátor může například automaticky přistupovat k frontě připojené za pozici kurzoru, ale ne k frontě vložené před tuto pozici. Výčet však můžete resetovat a tím přesunout kurzor zpět na začátek seznamu voláním ResetMessageQueueEnumerator.

V síti není definované řazení front. Enumerátor je neuspořádá, například podle počítače, štítku, veřejného nebo soukromého stavu ani podle jiných kritérií přístupnosti.

Pokud chcete statický snímek front v síti místo dynamického připojení k frontám, zavolejte GetPublicQueues nebo GetPrivateQueuesByMachine(String). Každá z těchto dvou metod vrátí pole MessageQueue objektů, které představují fronty v době volání metody.

Následující tabulka ukazuje, zda je tato metoda k dispozici v různých režimech pracovní skupiny.

Režim pracovní skupiny K dispozici.
Místní počítač No
Název místního počítače a přímého formátu No
Vzdálený počítač No
Název vzdáleného počítače a přímého formátu No

Viz také

Platí pro

GetMessageQueueEnumerator(MessageQueueCriteria)

Poskytuje dopřednou sémantiku kurzoru pro výčet všech veřejných front v síti, které splňují zadaná kritéria.

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

A MessageQueueCriteria obsahující kritéria používaná k filtrování dostupných front zpráv.

Návraty

A MessageQueueEnumerator , který poskytuje dynamický výpis veřejných front zpráv v síti, které splňují omezení určená parametrem criteria .

Příklady

Následující příklad kódu iteruje frontami zpráv a zobrazí cestu ke každé frontě, která byla vytvořena za poslední den a která existuje v počítači "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

Poznámky

Toto přetížení GetMessageQueueEnumerator vrátí seznam všech veřejných front v síti, které splňují kritéria definovaná v kritériích aplikace. Můžete zadat kritéria, která budou zahrnovat například čas vytvoření nebo úpravy fronty, název počítače, popisek, kategorii nebo libovolnou jejich kombinaci.

Vzhledem k tomu, že kurzor je přidružen k dynamickému výpisu, výčet odráží všechny změny provedené ve frontě, ke kterým dojde mimo aktuální pozici kurzoru. Změny front umístěných před aktuální pozicí kurzoru se neprojeví. Enumerátor může například automaticky přistupovat k frontě připojené za pozici kurzoru, ale ne k frontě vložené před tuto pozici. Výčet však můžete resetovat a tím přesunout kurzor zpět na začátek seznamu voláním ResetMessageQueueEnumerator.

V síti není definované řazení front. Enumerátor je neuspořádá, například podle počítače, štítku, veřejného nebo soukromého stavu ani podle jiných kritérií přístupnosti.

Pokud chcete statický snímek front v síti místo dynamického připojení k frontám, zadejte kritéria nebo GetPublicQueues volejte GetPrivateQueuesByMachine(String). Každá z těchto dvou metod vrátí pole MessageQueue objektů, které představují fronty v době volání metody. Volání GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String)nebo GetPublicQueuesByMachine(String) poskytuje stejné výsledky jako volání GetPublicQueues s kritérii Categoryfiltrování , Labela MachineNamev uvedeném pořadí.

Následující tabulka ukazuje, zda je tato metoda k dispozici v různých režimech pracovní skupiny.

Režim pracovní skupiny K dispozici.
Místní počítač No
Název místního počítače a přímého formátu No
Vzdálený počítač No
Název vzdáleného počítače a přímého formátu No

Viz také

Platí pro