MessageQueueEnumerator クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メッセージ キュー内のメッセージを列挙するための順方向専用カーソルを提供します。
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
- 継承
- 実装
例
次のコード例では、ネットワーク内のすべてのメッセージ キューを反復処理し、各キューのパスを調べます。 最後に、ネットワーク上のパブリック キューの数が表示されます。
#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
注釈
ネットワーク上のキューとの動的な対話には、 MessageQueueEnumerator を使用します。 MessageQueue クラスで使用できるメソッドは、キューの動的リストを含むMessageQueueEnumerator、または指定したメソッドが呼び出されたときのキュー コレクションのスナップショットを含む配列を返すことができます。
ネットワーク内のキューの順序は定義されていません。 これらは、たとえば、コンピューター、ラベル、パブリックまたはプライベートの状態、またはその他のユーザーがアクセス可能な条件で並べ替えされていません。 MessageQueueEnumeratorはカーソルであり、動的リストの先頭に初期化されます。 MoveNextを呼び出すことによって、列挙体の最初のキューにカーソルを移動できます。 列挙子が初期化されたら、 MoveNext を使用して、残りのキューを順を追って進めることができます。
MessageQueueEnumeratorを使用して戻ることはできません。 カーソルでは、キュー列挙体を前方に移動することのみが許可されます。 ただし、 Reset を呼び出して列挙をリセットし、もう一度リストの先頭にカーソルを置くことができます。 列挙子は動的であるため、カーソルの現在位置を超えて追加されたキューには、列挙子からアクセスできます。 カーソルの現在位置の前に挿入されたキューには、最初に Reset を呼び出さないとアクセスできません。
プロパティ
| 名前 | 説明 |
|---|---|
| Current |
列挙体の現在の MessageQueue を取得します。 |
| LocatorHandle |
ネットワーク内のキューの検索に使用されるネイティブ メッセージ キュー ハンドルを取得します。 |
メソッド
| 名前 | 説明 |
|---|---|
| Close() |
列挙子に関連付けられているリソースを解放します。 |
| CreateObjRef(Type) |
リモート オブジェクトとの通信に使用されるプロキシの生成に必要なすべての関連情報を含むオブジェクトを作成します。 (継承元 MarshalByRefObject) |
| Dispose() |
MessageQueueEnumeratorで使用されているすべてのリソースを解放します。 |
| Dispose(Boolean) |
MessageQueueEnumeratorによって使用されるアンマネージ リソースを解放し、必要に応じてマネージド リソースを解放します。 |
| Equals(Object) |
指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| Finalize() |
キューによって保持されているリソースを解放します。 |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetLifetimeService() |
古い.
このインスタンスの有効期間ポリシーを制御する現在の有効期間サービス オブジェクトを取得します。 (継承元 MarshalByRefObject) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| InitializeLifetimeService() |
古い.
このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。 (継承元 MarshalByRefObject) |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| MemberwiseClone(Boolean) |
現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。 (継承元 MarshalByRefObject) |
| MoveNext() |
列挙子が現在使用可能な場合は、列挙子を列挙の次のキューに進めます。 |
| Reset() |
カーソルをリセットして、列挙体の先頭を指します。 |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
| 名前 | 説明 |
|---|---|
| IEnumerator.Current |
列挙体の現在の MessageQueue を取得します。 |