MessageEnumeratorとは? わかりやすく解説

MessageEnumerator クラス

メッセージ キュー内のメッセージ列挙するための前方カーソル提供します

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Class MessageEnumerator
    Inherits MarshalByRefObject
    Implements IEnumerator, IDisposable
Dim instance As MessageEnumerator
public class MessageEnumerator : MarshalByRefObject,
 IEnumerator, IDisposable
public ref class MessageEnumerator : public
 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.Object
   System.MarshalByRefObject
    System.Messaging.MessageEnumerator
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MessageEnumerator メンバ
System.Messaging 名前空間
Message クラス
MessageQueue.GetMessageEnumerator2

MessageEnumerator プロパティ


パブリック プロパティパブリック プロパティ

明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IEnumerator.Current その列挙子が指している現在の Message取得します
参照参照

関連項目

MessageEnumerator クラス
System.Messaging 名前空間
Message クラス
MessageQueue.GetMessageEnumerator2

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 から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MessageEnumerator クラス
System.Messaging 名前空間
Message クラス
MessageQueue.GetMessageEnumerator2

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 から継承されます。)
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IEnumerator.Current その列挙子が指している現在の Message取得します
参照参照

関連項目

MessageEnumerator クラス
System.Messaging 名前空間
Message クラス
MessageQueue.GetMessageEnumerator2


このページでは「.NET Framework クラス ライブラリ リファレンス」からMessageEnumeratorを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMessageEnumeratorを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMessageEnumerator を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「MessageEnumerator」の関連用語

MessageEnumeratorのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MessageEnumeratorのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS