MessageEnumerator クラス
アセンブリ: System.Messaging (system.messaging.dll 内)

Public Class MessageEnumerator Inherits MarshalByRefObject Implements IEnumerator, IDisposable
public class MessageEnumerator : MarshalByRefObject, IEnumerator, IDisposable
public class MessageEnumerator extends MarshalByRefObject implements IEnumerator, IDisposable
public class MessageEnumerator extends MarshalByRefObject implements IEnumerator, IDisposable

キュー内のメッセージとの動的な対話には MessageEnumerator を使います。MessageQueue クラスを通じて使用できるメソッドは、キュー内のメッセージの動的リストを指す MessageEnumerator か、指定されたメソッドが呼び出された時点でのキューのコピー (スナップショット) を含む配列のいずれかを返すことができます。
静的なスナップショットと違い、列挙子を使うとコレクションを変更できます。MessageEnumerator を使うと、キューからメッセージを削除でき、その変更はキュー内ですぐに反映されます。
列挙子がキューを問い合わせるときには、列挙子はキューからメッセージを削除しません。列挙子は、現在のカーソル位置のメッセージについての情報を返しますが、キュー内のメッセージはそのままです。
MessageEnumerator はカーソルであり、初期化時に動的リストの先頭に配置されます。リストの順序は、キュー内のメッセージの順序 (メッセージの優先順位に従った順序) と同じです。MoveNext を呼び出すことで、キュー内の最初のメッセージにカーソルを移動させることができます。列挙子が初期化された後に、MoveNext を使って残りのメッセージを順に進んでいくことができます。MoveNext メソッドにタイムアウトを渡すことで、メッセージが使用できるようになるまで待機するかどうかを指定できます。
列挙子は動的であるため、カーソルの現在位置より後に追加されるメッセージ (優先順位が低いためなど) にもアクセスできます。しかし、カーソルの現在位置より前に挿入されているメッセージにはアクセスできません。MessageEnumerator で後方に移動することはできません。カーソルは前方にだけ移動できます。しかし、Reset メソッドを使うと、キューの先頭にカーソルを戻すことができます。
キューに対する MessageEnumerator の複数のインスタンスは、それぞれ個別に動作します。同じキューに適用される 2 つの MessageEnumerator のインスタンスを作成できます。その場合、第 1 の MessageEnumerator がキュー内のメッセージに行った変更は、第 2 の列挙子においてすぐに反映されます (第 2 の列挙子が第 1 の列挙子より前に位置しているとき)。しかし、2 つの列挙子の位置が同じときに一方の列挙子がその位置のメッセージを削除した場合は、既に削除されたメッセージの Current プロパティの値を他方の列挙子が取得しようとすると例外がスローされます。
![]() |
---|
MessageQueue.DenySharedReceive を true に設定して MessageQueue のインスタンスを作成すると、アプリケーションがキューに接続している間は他のアプリケーションによって列挙子内のメッセージが変更されなくなります。 |

キューにあるメッセージの動的リストを取得し、Priority プロパティが MessagePriority.Lowest に設定されたすべてのメッセージをカウントする例を次に示します。
Imports System Imports System.Messaging Public Class MyNewQueue ' Provides an entry point into the application. ' ' This example uses a cursor to step through the ' messages in a queue and counts the number of ' Lowest priority messages. Public Shared Sub Main() ' Create a new instance of the class. Dim myNewQueue As New MyNewQueue() ' Output the count of Lowest priority messages. myNewQueue.CountLowestPriority() Return End Sub 'Main ' Iterates through messages in a queue and examines ' their priority. Public Sub CountLowestPriority() ' Holds the count of Lowest priority messages. Dim numberItems As Int32 = 0 ' Connect to a queue. Dim myQueue As New MessageQueue(".\myQueue") ' Get a cursor into the messages in the queue. Dim myEnumerator As MessageEnumerator = _ myQueue.GetMessageEnumerator() ' Specify that the messages's priority should be read. myQueue.MessageReadPropertyFilter.Priority = True ' Move to the next message and examine its priority. While myEnumerator.MoveNext() ' Increase the count if the priority is Lowest. If myEnumerator.Current.Priority = _ MessagePriority.Lowest Then numberItems += 1 End If End While ' Display final count. Console.WriteLine(("Lowest priority messages: " + _ numberItems.ToString())) Return End Sub 'CountLowestPriority End Class 'MyNewQueue
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 // messages in a queue and counts the number of // Lowest priority messages. //************************************************** public static void Main() { // Create a new instance of the class. MyNewQueue myNewQueue = new MyNewQueue(); // Output the count of Lowest priority messages. myNewQueue.CountLowestPriority(); return; } //************************************************** // Iterates through messages in a queue and examines // their priority. //************************************************** public void CountLowestPriority() { // Holds the count of Lowest priority messages. uint numberItems = 0; // Connect to a queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Get a cursor into the messages in the queue. MessageEnumerator myEnumerator = myQueue.GetMessageEnumerator(); // Specify that the messages's priority should be read. myQueue.MessageReadPropertyFilter.Priority = true; // Move to the next message and examine its priority. while(myEnumerator.MoveNext()) { // Increase the count if priority is Lowest. if(myEnumerator.Current.Priority == MessagePriority.Lowest) numberItems++; } // Display final count. Console.WriteLine("Lowest priority messages: " + numberItems.ToString()); return; } } }
#using <system.dll> #using <system.messaging.dll> using namespace System; using namespace System::Messaging; ref class MyNewQueue { public: void CountLowestPriority() { // Holds the count of Lowest priority messages. UInt32 numberItems = 0; // Connect to a queue. MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); // Get a cursor into the messages in the queue. MessageEnumerator^ myEnumerator = myQueue->GetMessageEnumerator(); // Specify that the messages's priority should be read. myQueue->MessageReadPropertyFilter->Priority = true; // Move to the next message and examine its priority. while ( myEnumerator->MoveNext() ) { // Increase the count if priority is Lowest. if ( myEnumerator->Current->Priority == MessagePriority::Lowest ) numberItems++; } // Display final count. Console::WriteLine( "Lowest priority messages: {0}", numberItems ); return; } }; int main() { // Create a new instance of the class. MyNewQueue^ myNewQueue = gcnew MyNewQueue; // Output the count of Lowest priority messages. myNewQueue->CountLowestPriority(); return 0; }
package MyProject; import System.*; import System.Messaging.*; /// <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 // messages in a queue and counts the number of // Lowest priority messages. //************************************************** public static void main(String[] args) { // Create a new instance of the class. MyNewQueue myNewQueue = new MyNewQueue(); // Output the count of Lowest priority messages. myNewQueue.CountLowestPriority(); return; } //main //************************************************** // Iterates through messages in a queue and examines // their priority. //************************************************** public void CountLowestPriority() { // Holds the count of Lowest priority messages. long numberItems = 0; // Connect to a queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Get a cursor into the messages in the queue. MessageEnumerator myEnumerator = myQueue.GetMessageEnumerator(); // Specify that the messages's priority should be read. myQueue.get_MessageReadPropertyFilter().set_Priority(true); // Move to the next message and examine its priority. while (myEnumerator.MoveNext()) { // Increase the count if priority is Lowest. if (myEnumerator.get_Current().get_Priority(). Equals(MessagePriority.Lowest)) { numberItems++; } } // Display final count. Console.WriteLine("Lowest priority messages: " + ((Int32)numberItems).ToString()); return; } //CountLowestPriority } //MyNewQueue

System.MarshalByRefObject
System.Messaging.MessageEnumerator


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


MessageEnumerator プロパティ
MessageEnumerator メソッド

名前 | 説明 | |
---|---|---|
![]() | Close | 列挙子と関連付けられたリソースを解放します。 |
![]() | CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。) |
![]() | Dispose | オーバーロードされます。 MessageEnumerator によって使用されているリソースを解放します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | InitializeLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。) |
![]() | MoveNext | オーバーロードされます。 キュー内の次のメッセージに列挙子を進めます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | RemoveCurrent | オーバーロードされます。 キューから現在のメッセージを削除し、そのメッセージを呼び出し元アプリケーションに返します。メッセージを削除すると、そのメッセージがキューから削除されます。 |
![]() | Reset | キューの先頭を指すように現在の列挙子をリセットします。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 MessageEnumerator によって使用されているリソースを解放します。 |
![]() | Finalize | オーバーライドされます。 列挙子に保持されているリソースを解放します。 |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |

MessageEnumerator メンバ
メッセージ キュー内のメッセージを列挙するための前方向カーソルを提供します。
MessageEnumerator データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Close | 列挙子と関連付けられたリソースを解放します。 |
![]() | CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。) |
![]() | Dispose | オーバーロードされます。 MessageEnumerator によって使用されているリソースを解放します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | InitializeLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | MoveNext | オーバーロードされます。 キュー内の次のメッセージに列挙子を進めます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | RemoveCurrent | オーバーロードされます。 キューから現在のメッセージを削除し、そのメッセージを呼び出し元アプリケーションに返します。メッセージを削除すると、そのメッセージがキューから削除されます。 |
![]() | Reset | キューの先頭を指すように現在の列挙子をリセットします。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 MessageEnumerator によって使用されているリソースを解放します。 |
![]() | Finalize | オーバーライドされます。 列挙子に保持されているリソースを解放します。 |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |


Weblioに収録されているすべての辞書からMessageEnumeratorを検索する場合は、下記のリンクをクリックしてください。

- MessageEnumeratorのページへのリンク