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

Возвращаемое значение

A 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

В сети нет определенного порядка очередей. Перечислитель не упорядочиет их, например по компьютеру, метки, общедоступному или частному состоянию или любым другим критериям доступности.

Если требуется статический моментальный снимок очередей в сети, а не динамическое подключение к ним, вызов 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 , содержащее критерии, используемые для фильтрации доступных очередей сообщений.

Возвращаемое значение

A 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

В сети нет определенного порядка очередей. Перечислитель не упорядочиет их, например по компьютеру, метки, общедоступному или частному состоянию или любым другим критериям доступности.

Если требуется статический моментальный снимок очередей в сети, а не динамическое подключение к ним, укажите критерии для GetPublicQueues или вызова GetPrivateQueuesByMachine(String). Каждый из этих двух методов возвращает массив MessageQueue объектов, представляющих очереди во время вызова метода. Вызов GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String)или предоставляет те же результаты, что и GetPublicQueuesByMachine(String) вызов GetPublicQueues с критериями Categoryфильтрации , Labelи MachineNameсоответственно.

В следующей таблице показано, доступен ли этот метод в различных режимах рабочей группы.

Режим рабочей группы В наличии
Локальный компьютер Нет
Имя локального компьютера и прямого формата Нет
Удаленный компьютер Нет
Имя удаленного компьютера и прямого формата Нет

См. также раздел

Применяется к