MessageQueueEnumerator Třída

Definice

Poskytuje kurzor jen pro přeposílání výčtu zpráv ve frontě zpráv.

public ref class MessageQueueEnumerator : MarshalByRefObject, IDisposable, System::Collections::IEnumerator
public class MessageQueueEnumerator : MarshalByRefObject, IDisposable, System.Collections.IEnumerator
type MessageQueueEnumerator = class
    inherit MarshalByRefObject
    interface IEnumerator
    interface IDisposable
Public Class MessageQueueEnumerator
Inherits MarshalByRefObject
Implements IDisposable, IEnumerator
Dědičnost
MessageQueueEnumerator
Implementuje

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

Slouží MessageQueueEnumerator k dynamické interakci s frontami v síti. Metody dostupné prostřednictvím MessageQueue třídy mohou vracet buď MessageQueueEnumerator obsahující dynamický seznam front, nebo pole, které obsahuje snímek kolekce front v době, kdy byla volána zadaná metoda.

V síti není definované řazení front. Nejsou seřazené například podle počítače, popisku, veřejného nebo soukromého stavu nebo jiných kritérií přístupných uživatelem. A MessageQueueEnumerator je kurzor inicializovaný do hlavy dynamického seznamu. Kurzor můžete přesunout do první fronty výčtu voláním MoveNext. Po inicializaci enumerátoru můžete provést MoveNext krok vpřed mezi zbývajícími frontami.

Není možné krokovat zpět s MessageQueueEnumerator. Kurzor umožňuje pohyb vpřed pouze prostřednictvím výčtu fronty. Můžete však volat Reset resetování výčtu a znovu umístit kurzor na začátek seznamu. Vzhledem k tomu, že enumerátor je dynamický, je fronta, která je připojena za aktuální pozici kurzoru, může být přístupná enumerátorem. Fronta vložená před aktuální pozici kurzoru nelze získat přístup bez prvního volání resetování.

Vlastnosti

Name Description
Current

Získá aktuální MessageQueue výčet.

LocatorHandle

Získá nativní obslužný rutina řízení front zpráv použitá k vyhledání front v síti.

Metody

Name Description
Close()

Uvolní prostředky přidružené k enumerátoru.

CreateObjRef(Type)

Vytvoří objekt, který obsahuje všechny relevantní informace potřebné k vygenerování proxy serveru sloužícího ke komunikaci se vzdáleným objektem.

(Zděděno od MarshalByRefObject)
Dispose()

Uvolní všechny prostředky používané nástrojem MessageQueueEnumerator.

Dispose(Boolean)

Uvolní nespravované prostředky používané MessageQueueEnumerator a volitelně uvolní spravované prostředky.

Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
Finalize()

Uvolní prostředky uchovávané frontou.

GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetLifetimeService()
Zastaralé.

Načte objekt služby aktuální životnosti, který řídí zásady životnosti pro tuto instanci.

(Zděděno od MarshalByRefObject)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
InitializeLifetimeService()
Zastaralé.

Získá objekt služby životnosti pro řízení zásad životnosti pro tuto instanci.

(Zděděno od MarshalByRefObject)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
MemberwiseClone(Boolean)

Vytvoří mělkou kopii aktuálního MarshalByRefObject objektu.

(Zděděno od MarshalByRefObject)
MoveNext()

Přejde enumerátor na další frontu výčtu, pokud je aktuálně k dispozici.

Reset()

Obnoví kurzor, takže odkazuje na začátek výčtu.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

Name Description
IEnumerator.Current

Získá aktuální MessageQueue výčet.

Platí pro

Viz také