MessageQueue.GetMessageQueueEnumerator Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Создает объект перечислителя для динамического списка общих очередей сети.
Перегрузки
| GetMessageQueueEnumerator() |
Обеспечивает семантику курсора последовательного доступа для перечисления во всех общих очередях сети. |
| GetMessageQueueEnumerator(MessageQueueCriteria) |
Обеспечивает семантику курсора последовательного доступа для перечисления во всех общих очередях сети, удовлетворяющих указанным критериям. |
GetMessageQueueEnumerator()
Обеспечивает семантику курсора последовательного доступа для перечисления во всех общих очередях сети.
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
Возвращаемое значение
Объект MessageQueueEnumerator, обеспечивающий динамическое перечисление всех общих очередей сообщений в сети.
Примеры
В следующем примере кода выполняется итерацию по всем очередям сообщений в сети и проверяется путь для каждой очереди. Наконец, отображается количество общедоступных очередей в сети.
#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
Комментарии
Эта перегрузка GetMessageQueueEnumerator возвращает перечисление всех общедоступных очередей, которые находятся в сети.
Поскольку курсор связан с динамическим списком, перечисление отражает любые изменения, внесенные в список очередей для очередей, удаленных или добавленных за пределами текущей позиции курсора. Добавление или удаление очередей, расположенных до текущего положения курсора, не отражаются. Например, перечислитель может автоматически получить доступ к очереди, добавленной за пределами позиции курсора, но не к очереди, вставленной перед этой позицией. Однако можно сбросить перечисление, тем самым переместив курсор обратно в начало списка, вызвав Reset для MessageQueueEnumerator.
В сети нет определенного порядка очередей. Перечислитель не упорядочиет их, например, по компьютеру, метки, общедоступному или частному состоянию, а также по любым другим доступным критериям.
Если требуется статическое snapshot очередей в сети, а не динамическое подключение к ним, вызовите GetPublicQueues или GetPrivateQueuesByMachine(String). Каждый из этих двух методов возвращает массив MessageQueue объектов , которые представляют очереди на момент вызова метода.
В следующей таблице показано, доступен ли этот метод в различных режимах рабочей группы.
| Режим рабочей группы | Доступно |
|---|---|
| Локальный компьютер | Нет |
| Имя локального компьютера и прямого формата | Нет |
| Удаленный компьютер | Нет |
| Имя удаленного компьютера и прямого формата | Нет |
См. также раздел
Применяется к
GetMessageQueueEnumerator(MessageQueueCriteria)
Обеспечивает семантику курсора последовательного доступа для перечисления во всех общих очередях сети, удовлетворяющих указанным критериям.
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
Параметры
- criteria
- MessageQueueCriteria
Объект MessageQueueCriteria, содержащий критерии фильтрации доступных очередей сообщений.
Возвращаемое значение
Объект MessageQueueEnumerator, обеспечивающий динамическое перечисление общих очередей сообщений сети, удовлетворяющих ограничениям, заданным параметром criteria.
Примеры
В следующем примере кода выполняется итерацию по очередям сообщений и отображается путь к каждой очереди, созданной за последний день и существующей на компьютере 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
Комментарии
Эта перегрузка GetMessageQueueEnumerator возвращает список всех общедоступных очередей в сети, соответствующих критериям, определенным в критериях приложения. Можно указать критерии для включения, например, времени создания или изменения очереди, имени компьютера, метки, категории или любого их сочетания.
Поскольку курсор связан с динамическим листингом, перечисление отражает любые изменения, внесенные в очередь, которая происходит за пределами текущей позиции курсора. Изменения очередей, расположенных до текущего положения курсора, не отражаются. Например, перечислитель может автоматически получить доступ к очереди, добавленной за пределами позиции курсора, но не к очереди, вставленной перед этой позицией. Однако можно сбросить перечисление, тем самым переместив курсор обратно в начало списка, вызвав Reset для MessageQueueEnumerator.
В сети нет определенного порядка очередей. Перечислитель не упорядочиет их, например, по компьютеру, метки, общедоступному или частному состоянию, а также по любым другим доступным критериям.
Если требуется статическое snapshot очередей в сети, а не динамическое подключение к ним, укажите условия для GetPublicQueues или вызовите GetPrivateQueuesByMachine(String). Каждый из этих двух методов возвращает массив MessageQueue объектов , которые представляют очереди на момент вызова метода. Вызов GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String)или GetPublicQueuesByMachine(String) дает те же результаты, что и вызов GetPublicQueues с критериями Categoryфильтрации , Labelи MachineNameсоответственно.
В следующей таблице показано, доступен ли этот метод в различных режимах рабочей группы.
| Режим рабочей группы | Доступно |
|---|---|
| Локальный компьютер | Нет |
| Имя локального компьютера и прямого формата | Нет |
| Удаленный компьютер | Нет |
| Имя удаленного компьютера и прямого формата | Нет |