다음을 통해 공유


MSMQEvent.Arrived

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The Arrived event of the MSMQEvent object is fired when the MSMQQueue.EnableNotification method of an instance of the MSMQQueue object representing an open queue has been called and a message is found or arrives at the applicable position in the queue.

Event Arrived( _  
  ByVal Queue As Object, _  
  ByVal Cursor As Long _  
)  

Parameters

Queue

Queue (MSMQQueue) object passed by value that represents an open instance of the queue where the message arrived.

Cursor

Long passed by value that contains the value of the Cursor argument in the call to MSMQQueue.EnableNotification that initiated event notification. Its value may be MQMSG_FIRST (the default value for EnableNotification), MQMSG_CURRENT, or MQMSG_NEXT. Refer to this value when re-enabling notification within your event handler.

Remarks

The Arrived event is fired by an instance of the MSMQEvent object. Every queue that has called MSMQQueue.EnableNotification triggers an instance of the MSMQEvent object when a message arrives at the specific cursor location in the queue (this includes existing messages in the queue when EnableNotification is first called).

MSMQQueue.EnableNotification can be called with its Cursor parameter set to MQMSG_FIRST (the default value) to signal a notification whenever there is a message in the queue, or it can be called with the Cursor parameter set to a combination of MQMSG_CURRENT and MQMSG_NEXT values to traverse the queue. Regardless of the Cursor parameter setting, MSMQQueue.EnableNotification must be called to start notification and explicitly reset notification after each Arrived event is fired.

There is no association between an Arrived event and a specific message. The arrived event only means that some message arrived at a specific location in the queue.

Although an Arrived event is fired for a message, there is no guarantee that the message that triggered the event will still be there when the event handler tries to read the message. Queues are dynamic, and another application may have already removed the message that triggered the Arrived event.

For information on See
How cursors behave Navigating with Cursors

Example Code

The following examples are included in Using Message Queuing.

For an example of See
Writing an arrived event handler that navigates a queue C/C++ COM Code Example: Reading Messages Asynchronously

 Visual Basic Code Example: Reading Messages Asynchronously

Requirements

Windows NT/2000/XP:Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQQueue.EnableNotification
MSMQEvent
MSMQQueue