MessageQueue.GetMessageQueueEnumerator メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ネットワーク上のパブリック キューの動的リストの列挙子オブジェクトを作成します。
オーバーロード
| 名前 | 説明 |
|---|---|
| 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のこのオーバーロードは、ネットワーク上にあるすべてのパブリック キューの列挙を返します。
カーソルは動的リストに関連付けられているため、列挙体には、カーソルの現在位置を超えて削除または追加されたキューのキュー リストに加えた変更が反映されます。 カーソルの現在位置の前にあるキューの追加または削除は反映されません。 たとえば、列挙子は、カーソル位置の後に追加されたキューに自動的にアクセスできますが、その位置の前に挿入されたキューにはアクセスできません。 ただし、列挙をリセットして、カーソルをリストの先頭に戻すには、MessageQueueEnumeratorのResetを呼び出します。
ネットワーク内のキューの順序は定義されていません。 列挙子は、コンピューター、ラベル、パブリックまたはプライベートの状態、その他のアクセス可能な条件など、それらを並べ替えません。
動的接続ではなく、ネットワーク上のキューの静的スナップショットが必要な場合は、 GetPublicQueues または GetPrivateQueuesByMachine(String)を呼び出します。 これら 2 つの各メソッドは、 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 。
返品
criteria パラメーターで指定された制限を満たすネットワーク上のパブリック メッセージ キューの動的な一覧を提供するMessageQueueEnumerator。
例
次のコード例では、メッセージ キューを反復処理し、最後の日に作成され、コンピューター "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 オーバーロードは、アプリケーション条件で定義された条件を満たすネットワーク上のすべてのパブリック キューの一覧を返します。 キューの作成または変更時刻、コンピューター名、ラベル、カテゴリ、またはこれらの任意の組み合わせなど、含める条件を指定できます。
カーソルは動的リストに関連付けられているため、列挙は、カーソルの現在位置を超えて発生するキューに加えた変更を反映します。 カーソルの現在位置より前にあるキューへの変更は反映されません。 たとえば、列挙子は、カーソル位置の後に追加されたキューに自動的にアクセスできますが、その位置の前に挿入されたキューにはアクセスできません。 ただし、列挙をリセットして、カーソルをリストの先頭に戻すには、MessageQueueEnumeratorのResetを呼び出します。
ネットワーク内のキューの順序は定義されていません。 列挙子は、コンピューター、ラベル、パブリックまたはプライベートの状態、その他のアクセス可能な条件など、それらを並べ替えません。
動的接続ではなく、ネットワーク上のキューの静的スナップショットが必要な場合は、 GetPublicQueues の条件を指定するか、 GetPrivateQueuesByMachine(String)を呼び出します。 これら 2 つの各メソッドは、 MessageQueue オブジェクトの配列を返します。これは、メソッドが呼び出されたときのキューを表します。 GetPublicQueuesByCategory(Guid)、GetPublicQueuesByLabel(String)、またはGetPublicQueuesByMachine(String)を呼び出すと、Category、Label、MachineNameのフィルター条件でGetPublicQueuesを呼び出すのと同じ結果が得られます。
次の表は、このメソッドがさまざまなワークグループ モードで使用できるかどうかを示しています。
| ワークグループ モード | 在庫有り |
|---|---|
| ローカル コンピューター | いいえ |
| ローカル コンピューターと直接の形式名 | いいえ |
| リモート コンピューター | いいえ |
| リモート コンピューターと直接の形式名 | いいえ |