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!

Asynchronous Message Processing

You can retrieve messages asynchronously if you want to retrieve messages without tying up your application's processing. In asynchronous message processing, the method that starts a task is returned immediately without waiting for a result. The application can continue to do what it was originally doing while the task is completed. When the task completes, the server can notify the application that the message was successfully processed.

There are two types of asynchronous processes you can perform with the MessageQueue component:

Receiving Notification of Your Asynchronous Operation

There are two ways you can receive notification when your asynchronous receive or peek operation completes successfully:

When you use event notification, you create a method that handles your message processing and returns a notification when the processing completes. You then call the method that begins the asynchronous processing.

In the event notification scenario, BeginPeek or BeginReceive returns a single message and then stops processing. You must call BeginPeek or BeginReceive again for each message you want to retrieve.

An alternate way to process messages asynchronously is to use a callback. A callback identifies a delegate you want to associate with your BeginPeek or BeginReceive operations. In this scenario, the delegate continues to watch for new event notification after each message is processed.

See Also

Receiving Messages Asynchronously | Reading and Receiving Messages | Peeking at Messages Asynchronously | Peeking at Messages | Receiving Messages Programmatically