Bagikan melalui


MessageQueue.GetEnumerator Metode

Definisi

Perhatian

This method returns a MessageEnumerator that implements RemoveCurrent family of methods incorrectly. Please use GetMessageEnumerator2 instead.

Menghitung pesan dalam antrean. GetEnumerator() tidak digunakan lagi. GetMessageEnumerator2() harus digunakan sebagai gantinya.

public:
 virtual System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator ();
[System.Obsolete("This method returns a MessageEnumerator that implements RemoveCurrent family of methods incorrectly. Please use GetMessageEnumerator2 instead.")]
public System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
[<System.Obsolete("This method returns a MessageEnumerator that implements RemoveCurrent family of methods incorrectly. Please use GetMessageEnumerator2 instead.")>]
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator

Mengembalikan

IEnumerator yang menyediakan koneksi dinamis ke pesan dalam antrean.

Penerapan

Atribut

Contoh

Contoh kode berikut menunjukkan penggunaan GetEnumerator.


// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

// Get an IEnumerator object.
System::Collections::IEnumerator^ enumerator = 
    queue->GetMessageEnumerator2();

// Use the IEnumerator object to loop through the messages.
while(enumerator->MoveNext())
{
    // Get a message from the enumerator.
    Message^ msg = (Message^)enumerator->Current;

    // Display the label of the message.
    Console::WriteLine(msg->Label);
}

queue->Close();

// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Get an IEnumerator object.
System.Collections.IEnumerator enumerator = queue.GetEnumerator();

// Use the IEnumerator object to loop through the messages.
while(enumerator.MoveNext())
{
    // Get a message from the enumerator.
    Message msg = (Message)enumerator.Current;

    // Display the label of the message.
    Console.WriteLine(msg.Label);
}

Keterangan

Tabel berikut ini memperlihatkan apakah metode ini tersedia dalam berbagai mode Grup Kerja.

Mode grup kerja Tersedia
Komputer lokal Ya
Komputer lokal dan nama format langsung Ya
Komputer jarak jauh Tidak
Komputer jarak jauh dan nama format langsung Ya

Berlaku untuk

Lihat juga