MessageQueueEnumerator Třída

Definice

Poskytuje kurzor jen pro přeposlání pro výčet 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 vrátit 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ý na začátek dynamického seznamu. Kurzor můžete přesunout do první fronty výčtu voláním MoveNext. Po inicializaci enumerátoru můžete použít MoveNext k procházení zbývajících front vpřed.

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

Vlastnosti

Current

Získá proud MessageQueue výčtu.

LocatorHandle

Získá nativní popisovač služby Řízení front zpráv používaný k vyhledání front v síti.

Metody

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 používané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 nástrojem a volitelně uvolní spravované prostředky.

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

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

Uvolní prostředky, které jsou ve frontě.

GetHashCode()

Slouží jako výchozí hashovací funkce.

(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á aktuální Type instanci.

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

Získá objekt služby životnosti, který řídí zásady životnosti pro tuto instanci.

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

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

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

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

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

Posune enumerátor do další fronty 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í

IEnumerator.Current

Získá proud MessageQueue výčtu.

Platí pro

Viz také