MessageQueue.GetMessageQueueEnumerator Metoda

Definice

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

Přetížení

Name Description
GetMessageQueueEnumerator()

Poskytuje sémantiku kurzoru jen pro předávání pro výčet všech veřejných front v síti.

GetMessageQueueEnumerator(MessageQueueCriteria)

Poskytuje sémantiku kurzoru určenou jen pro předávání, která se má vypsat prostřednictvím všech veřejných front v síti, které splňují zadaná kritéria.

GetMessageQueueEnumerator()

Poskytuje sémantiku kurzoru jen pro předávání pro výčet všech veřejných front 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, bude výčet odrážet 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 jedné vložené před tuto pozici. Můžete však obnovit výčet, čímž přesunete kurzor zpět na začátek seznamu voláním ResetMessageQueueEnumeratorpro .

V síti není definované řazení front. Enumerátor je například nezařadí podle počítače, popisku, veřejného nebo soukromého stavu nebo jakéhokoli jiného přístupného kritéria.

Chcete-li statický snímek front v síti, nikoli dynamické připojení k nim, volání GetPublicQueues nebo GetPrivateQueuesByMachine(String). Každá z těchto dvou metod vrátí pole MessageQueue objektů, které představují fronty v době, kdy byla volána metoda.

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

Režim pracovní skupiny Available
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 sémantiku kurzoru určenou jen pro předávání, která se má vypsat prostřednictvím 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žitá k filtrování dostupných front zpráv.

Návraty

A MessageQueueEnumerator , který poskytuje dynamický výpis front veřejných 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 v posledním dni 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á se mají zahrnout, například čas vytvoření fronty nebo úpravy, název počítače, popisek, kategorie nebo libovolná jejich kombinace.

Vzhledem k tomu, že kurzor je přidružený k dynamickému výpisu, bude výčet odrážet všechny změny provedené ve frontě, které se nachází 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 jedné vložené před tuto pozici. Můžete však obnovit výčet, čímž přesunete kurzor zpět na začátek seznamu voláním ResetMessageQueueEnumeratorpro .

V síti není definované řazení front. Enumerátor je například nezařadí podle počítače, popisku, veřejného nebo soukromého stavu nebo jakéhokoli jiného přístupného kritéria.

Pokud chcete statický snímek front v síti namísto dynamického připojení k nim, zadejte kritéria pro GetPublicQueues volání nebo volání GetPrivateQueuesByMachine(String). Každá z těchto dvou metod vrátí pole MessageQueue objektů, které představují fronty v době, kdy byla volána metoda. Volání GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String)nebo GetPublicQueuesByMachine(String) poskytuje stejné výsledky jako volání GetPublicQueues s filtrovacími kritérii Category, Labela MachineName, v 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 Available
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