MessageQueueEnumerator MessageQueueEnumerator MessageQueueEnumerator MessageQueueEnumerator Class

定義

提供順向資料指標,進而列舉訊息佇列中的訊息。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
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

備註

使用MessageQueueEnumerator佇列在網路上的動態互動。Use 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. AMessageQueueEnumerator是資料指標,初始化為動態清單的標頭。A MessageQueueEnumerator is a cursor, initialized to the head of a dynamic list. 您可以將游標移至列舉型別的第一個佇列藉由呼叫MoveNextYou 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.

不可能向後步驟來搭配MessageQueueEnumeratorIt 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.

適用於

另請參閱