MessageQueueEnumerator MessageQueueEnumerator MessageQueueEnumerator MessageQueueEnumerator Class

定義

提供順向資料指標 (Cursor),以列舉訊息佇列中的訊息。Provides a forward-only cursor to enumerate through messages in a message queue.

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
繼承
MessageQueueEnumeratorMessageQueueEnumeratorMessageQueueEnumeratorMessageQueueEnumerator
實作

範例

下列程式碼範例會逐一查看網路中的所有訊息佇列, 並檢查每個佇列的路徑。The following code example iterates through all the message queues in the network, and examines the path for each queue. 最後, 它會顯示網路上的公用佇列數目。Finally, it displays the number of public queues on the network.

#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 'Main


        
        ' 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 'ListPublicQueues

End Class 'MyNewQueue

備註

用於與網路上的佇列進行動態互動。MessageQueueEnumeratorUse MessageQueueEnumerator for dynamic interaction with queues on the network. 透過MessageQueue類別提供的方法可以傳回包含佇列MessageQueueEnumerator動態清單的, 或在呼叫指定的方法時, 包含佇列集合快照集的陣列。Methods available through the MessageQueue class can return either a MessageQueueEnumerator containing a dynamic list of queues, or an array that contains a snapshot of the queue collection at the time the specified method was called.

網路中沒有已定義的佇列排序。There is no defined ordering of queues in a network. 它們不會依電腦、標籤、公用或私用狀態或其他使用者可存取的準則進行排序。They are not ordered, for example, by computer, label, public or private status, or other user-accessible criteria. MessageQueueEnumerator是一種資料指標, 已初始化為動態清單的標頭。A MessageQueueEnumerator is a cursor, initialized to the head of a dynamic list. 您可以藉由呼叫MoveNext, 將游標移至列舉的第一個佇列。You can move the cursor to the first queue of the enumeration by calling MoveNext. 初始化枚舉器之後, 您可以使用MoveNext逐步執行其餘的佇列。After the enumerator has been initialized, you can use MoveNext to step forward through the remaining queues.

不可能以回溯方式MessageQueueEnumerator執行。It is not possible to step backward with a MessageQueueEnumerator. 資料指標只允許透過佇列列舉向前移動。A cursor only allows forward movement through the queue enumeration. 不過, 您可以呼叫Reset來重設列舉, 並將游標再次放在清單的開頭。However, you can call Reset to reset the enumeration and put the cursor at the beginning of the list again. 因為列舉值是動態的, 所以在資料指標目前位置之後附加的佇列, 可以透過列舉值來存取。Because the enumerator is dynamic, a queue that is appended beyond the cursor's current position can be accessed by the enumerator. 在沒有第一次呼叫 Reset 的情況下, 無法存取在資料指標目前位置之前插入的佇列。A queue that is inserted before the cursor's current position cannot be accessed without first calling Reset.

屬性

Current Current Current Current

取得列舉型別的目前 MessageQueueGets the current MessageQueue of the enumeration.

LocatorHandle LocatorHandle LocatorHandle LocatorHandle

取得用來尋找網路中佇列的原生 (Native) 訊息佇列控制代碼。Gets the native Message Queuing handle used to locate queues in a network.

方法

Close() Close() Close() Close()

釋放與列舉值相關的資源。Frees the resources associated with the enumerator.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放 MessageQueueEnumerator 所使用的所有資源。Releases all resources used by the MessageQueueEnumerator.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 MessageQueueEnumerator 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the MessageQueueEnumerator and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

釋出佇列所持有的資源。Releases the resources held by the queue.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
MoveNext() MoveNext() MoveNext() MoveNext()

如果目前有可用的列舉值,讓列舉值前進至列舉型別的下一個佇列。Advances the enumerator to the next queue of the enumeration, if one is currently available.

Reset() Reset() Reset() Reset()

重設資料指標,讓它指向列舉型別的開頭。Resets the cursor, so it points to the beginning of the enumeration.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

IEnumerator.Current IEnumerator.Current IEnumerator.Current IEnumerator.Current

取得列舉型別的目前 MessageQueueGets the current MessageQueue of the enumeration.

適用於

另請參閱