NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Peeking at Messages Asynchronously

You can peek at messages asynchronously in two ways: by using an event handler to receive notification when the operation finishes processing, or by using a callback. This procedure explains how to use event notification.

In event notification, you first bind an event handler to the procedure you want to run when the asynchronous call completes. You then call the BeginPeek method in your code. This starts the asynchronous processing and returns processing to your component. When the processing completes, the an event you've defined is raised and the results of the retrieval are processed.

Note   BeginPeek will retrieve only a single message. If you want to continue peeking at messages asynchronously, you must either call BeginPeek again or use the callback parameter on BeginPeek to call a delegate that will continue to watch for new messages arriving on the queue.

See Also

Asynchronous Message Processing | Receiving Messages Asynchronously | Reading and Receiving Messages | Peeking at Messages | Receiving Messages Programmatically | Creating MessageQueue Components